diff --git a/pkg/api/v1beta1/pools/http.go b/pkg/api/v1beta1/pools/http.go index d449b7a5..3b326f06 100644 --- a/pkg/api/v1beta1/pools/http.go +++ b/pkg/api/v1beta1/pools/http.go @@ -57,6 +57,14 @@ func (r *GetPoolsRequest) UnmarshalHTTPRequest(c echo.Context) error { return nil } +// IsLegacy checks if request contains deprecated query parameters. +// It's used to determine backward compatibility. +func (r *GetPoolsRequest) IsLegacy(c echo.Context) bool { + return c.QueryParam(queryIDs) != "" || + c.QueryParam(queryMinLiquidityCap) != "" || + c.QueryParam(queryWithMarketIncentives) != "" +} + // IsPresent checks if the pagination request is present in the HTTP request. func (r *GetPoolsRequestFilter) IsPresent(c echo.Context) bool { return c.QueryParam(queryIDs) != "" || diff --git a/pools/delivery/http/pools_handler.go b/pools/delivery/http/pools_handler.go index 80a8f492..e8d15cf2 100644 --- a/pools/delivery/http/pools_handler.go +++ b/pools/delivery/http/pools_handler.go @@ -105,7 +105,7 @@ func (a *PoolsHandler) GetPools(c echo.Context) error { } // Convert pools to the appropriate format - resultPools := convertPoolsToResponse(&req, pools, total) + resultPools := convertPoolsToResponse(c, &req, pools, total) return c.JSON(http.StatusOK, resultPools) } @@ -210,12 +210,16 @@ func convertPoolToResponse(pool sqsdomain.PoolI) PoolResponse { } // convertPoolsToResponse converts the given pools to the appropriate response type. -func convertPoolsToResponse(req *api.GetPoolsRequest, p []sqsdomain.PoolI, total uint64) *GetPoolsResponse { +func convertPoolsToResponse(c echo.Context, req *api.GetPoolsRequest, p []sqsdomain.PoolI, total uint64) any { pools := make([]PoolResponse, 0, len(p)) for _, pool := range p { pools = append(pools, convertPoolToResponse(pool)) } + if req.IsLegacy(c) { + return pools // backward compatibility + } + return &GetPoolsResponse{ Data: pools, Meta: v1beta1.NewPaginationResponse(req.Pagination, total),