Add endpoint for all messages
This commit is contained in:
@ -328,6 +328,30 @@ func (cont *Controller) GetLogs(ctx *gin.Context) {
|
||||
ctx.JSON(http.StatusOK, logs)
|
||||
}
|
||||
|
||||
// AllMessages godoc
|
||||
// @Summary List all FIX application messages of the day
|
||||
// @Description Returns every FIX application message recorded today (no admin: heartbeats/logon/logout/etc.), sorted by CreatedAt ascending
|
||||
// @Tags fix
|
||||
// @Produce json
|
||||
// @Success 200 {array} domain.Message
|
||||
// @Router /qfixdpl/v1/messages [post]
|
||||
func (cont *Controller) AllMessages(ctx *gin.Context) {
|
||||
setHeaders(ctx, cont.config)
|
||||
|
||||
var req AllMessagesRequest
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
ctx.JSON(http.StatusBadRequest, HTTPError{Error: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
if req.APIKey != "1234" {
|
||||
ctx.JSON(http.StatusUnauthorized, HTTPError{Error: "Not allowed to perform this request"})
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, cont.tradeProvider.GetAllMessages())
|
||||
}
|
||||
|
||||
// GetPendingQuoteRequests godoc
|
||||
// @Summary List pending QuoteRequests
|
||||
// @Description Returns all QuoteRequests received from TW that have not been quoted yet by the dealer
|
||||
@ -381,4 +405,3 @@ func (cont *Controller) SendQuote(ctx *gin.Context) {
|
||||
|
||||
ctx.JSON(http.StatusOK, Msg{Text: "Quote sent"})
|
||||
}
|
||||
|
||||
|
||||
@ -21,3 +21,7 @@ type SendQuoteRequest struct {
|
||||
QuoteReqID string `json:"QuoteReqID" binding:"required"`
|
||||
Price string `json:"Price" binding:"required" example:"99.6"`
|
||||
}
|
||||
|
||||
type AllMessagesRequest struct {
|
||||
APIKey string
|
||||
}
|
||||
|
||||
@ -26,6 +26,9 @@ func SetRoutes(api *API) {
|
||||
qfixdpl.GET("/quote-requests", cont.GetPendingQuoteRequests)
|
||||
qfixdpl.POST("/quotes", cont.SendQuote)
|
||||
|
||||
msgs := v1.Group("/")
|
||||
msgs.POST("/messages", cont.AllMessages)
|
||||
|
||||
backoffice := qfixdpl.Group("/backoffice")
|
||||
backoffice.Use(cont.BackOfficeUser)
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ type TradeProvider interface {
|
||||
GetTrades() []domain.ListTrade
|
||||
GetPendingQuoteRequests() []domain.ListTrade
|
||||
SendQuote(quoteReqID string, price decimal.Decimal) error
|
||||
GetAllMessages() []domain.Message
|
||||
}
|
||||
|
||||
const RedisMaxIdle = 3000 // In ms
|
||||
|
||||
Reference in New Issue
Block a user