mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-12-23 02:07:32 +01:00
Mohammed Sohail
add7f2a442
* use context timeout middleware for correct ctx propagation * Fix bind error handling * Fix validation error handling * Fix HTTP error handling (4XX) * tasker client now accepts ctx * add recovery and body size middleware
43 lines
865 B
Go
43 lines
865 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/grassrootseconomics/cic-custodial/internal/custodial"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// HandleTxStatus route.
|
|
// GET: /api/track/:trackingId
|
|
// Route param:
|
|
// trackingId -> tracking UUID
|
|
// Returns array of tx status.
|
|
func HandleTrackTx(c echo.Context) error {
|
|
var (
|
|
cu = c.Get("cu").(*custodial.Custodial)
|
|
txStatusRequest struct {
|
|
TrackingId string `param:"trackingId" validate:"required,uuid"`
|
|
}
|
|
)
|
|
|
|
if err := c.Bind(&txStatusRequest); err != nil {
|
|
return NewBadRequestError(err)
|
|
}
|
|
|
|
if err := c.Validate(txStatusRequest); err != nil {
|
|
return err
|
|
}
|
|
|
|
txs, err := cu.PgStore.GetTxStatusByTrackingId(c.Request().Context(), txStatusRequest.TrackingId)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, OkResp{
|
|
Ok: true,
|
|
Result: H{
|
|
"transactions": txs,
|
|
},
|
|
})
|
|
}
|