Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nourbalaha committed Nov 6, 2024
1 parent 08c0302 commit 5c01ae6
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions server/internal/adapter/publicapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func Echo(e *echo.Group) {
e.Use(middleware.CORS())
e.GET("/:project/:model", publicApiItemOrAssetList())
e.GET("/:project/:model/:item", publicApiItemOrAsset())
e.GET("/:project/:model/:schema", publicApiSchema())
}

func publicApiItemOrAsset() echo.HandlerFunc {
Expand All @@ -44,6 +43,14 @@ func publicApiItemOrAsset() echo.HandlerFunc {
ctrl := GetController(c.Request().Context())

p, m, i := c.Param("project"), c.Param("model"), c.Param("item")
if i == "schema.json" {
res, err := ctrl.getSchema(ctx, p, m)
if err != nil {
return err
}
return c.JSON(http.StatusOK, res)
}

var res any
var err error
if m == "assets" {
Expand All @@ -60,25 +67,6 @@ func publicApiItemOrAsset() echo.HandlerFunc {
}
}

func publicApiSchema() echo.HandlerFunc {
return func(c echo.Context) error {
ctx := c.Request().Context()
ctrl := GetController(c.Request().Context())

p, m, s := c.Param("project"), c.Param("model"), c.Param("schema")
var res any
var err error
if s == "schema.json" {
res, err = ctrl.getSchema(ctx, p, m)
}
if err != nil {
return err
}

return c.JSON(http.StatusOK, res)
}
}

func publicApiItemOrAssetList() echo.HandlerFunc {
return func(c echo.Context) error {
ctx := c.Request().Context()
Expand Down

0 comments on commit 5c01ae6

Please sign in to comment.