Skip to content

Commit

Permalink
Update UI Server
Browse files Browse the repository at this point in the history
  • Loading branch information
temporal-data committed Jan 17, 2024
1 parent aa6fe56 commit d26b9af
Show file tree
Hide file tree
Showing 122 changed files with 139 additions and 115 deletions.
24 changes: 23 additions & 1 deletion server/route/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,38 @@
package route

import (
"net/http"

"github.com/labstack/echo/v4"

"github.com/temporalio/ui-server/v2/server/api"
"github.com/temporalio/ui-server/v2/server/config"
)

func DisableWriteMiddleware(cfgProvider *config.ConfigProviderWithRefresh) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
cfg, err := cfgProvider.GetConfig()
if err != nil {
return c.JSON(http.StatusInternalServerError, err)
}

if cfg.DisableWriteActions && c.Request().Method != http.MethodGet {
return echo.ErrMethodNotAllowed
}

return next(c)
}
}
}

// SetAPIRoutes sets api routes
func SetAPIRoutes(e *echo.Echo, cfgProvider *config.ConfigProviderWithRefresh, apiMiddleware []api.Middleware) error {
route := e.Group("/api")
route.GET("/v1/settings", api.GetSettings(cfgProvider))
route.Match([]string{"GET", "POST", "PUT", "PATCH", "DELETE"}, "/*", api.TemporalAPIHandler(cfgProvider, apiMiddleware))

writeControlMiddleware := DisableWriteMiddleware(cfgProvider)

route.Match([]string{"GET", "POST", "PUT", "PATCH", "DELETE"}, "/*", api.TemporalAPIHandler(cfgProvider, apiMiddleware), writeControlMiddleware)
return nil
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d26b9af

Please sign in to comment.