2023-09-10 15:39:34 +00:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"git.ekzyis.com/ekzyis/delphi.market/db"
|
2023-10-04 11:36:54 +00:00
|
|
|
"git.ekzyis.com/ekzyis/delphi.market/server/router/context"
|
2024-07-09 20:41:29 +00:00
|
|
|
"git.ekzyis.com/ekzyis/delphi.market/server/router/pages"
|
2023-09-10 15:39:34 +00:00
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
)
|
|
|
|
|
2024-07-09 20:41:29 +00:00
|
|
|
func HandleIndex(sc context.Context) echo.HandlerFunc {
|
2023-09-10 15:39:34 +00:00
|
|
|
return func(c echo.Context) error {
|
2024-07-09 20:41:29 +00:00
|
|
|
return pages.Index().Render(context.RenderContext(sc, c), c.Response().Writer)
|
2023-09-10 15:39:34 +00:00
|
|
|
}
|
|
|
|
}
|
2023-11-08 02:00:47 +00:00
|
|
|
|
2024-07-09 20:41:29 +00:00
|
|
|
func HandleMarkets(sc context.Context) echo.HandlerFunc {
|
2023-11-08 02:00:47 +00:00
|
|
|
return func(c echo.Context) error {
|
|
|
|
var (
|
|
|
|
markets []db.Market
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
if err = sc.Db.FetchActiveMarkets(&markets); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, markets)
|
|
|
|
}
|
|
|
|
}
|