delphi.market/server/router/handler/index.go

30 lines
685 B
Go
Raw Normal View History

package handler
import (
"net/http"
"git.ekzyis.com/ekzyis/delphi.market/db"
"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"
"github.com/labstack/echo/v4"
)
2024-07-09 20:41:29 +00:00
func HandleIndex(sc context.Context) echo.HandlerFunc {
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-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)
}
}