diff --git a/server/routes/api.go b/server/routes/api.go index 6e750ac288..f102ed2f58 100644 --- a/server/routes/api.go +++ b/server/routes/api.go @@ -30,16 +30,18 @@ import ( "github.com/labstack/echo-contrib/session" "github.com/labstack/echo/v4" "golang.org/x/net/context" + "google.golang.org/grpc" "google.golang.org/grpc/metadata" + "github.com/temporalio/ui-server/server/config" "github.com/temporalio/ui-server/server/generated/api/workflowservice/v1" - "google.golang.org/grpc" ) // SetAPIRoutes sets api routes -func SetAPIRoutes(e *echo.Echo, temporalConn *grpc.ClientConn) error { +func SetAPIRoutes(e *echo.Echo, cfg *config.Config, temporalConn *grpc.ClientConn) error { api := e.Group("/api") api.GET("/v1/me", getCurrentUser) + api.GET("/v1/settings", getSettings(cfg)) api.Match([]string{"GET", "POST", "PUT", "PATCH", "DELETE"}, "/*", temporalAPIHandler(temporalConn)) return nil } @@ -90,6 +92,22 @@ func getCurrentUser(c echo.Context) error { return c.JSON(http.StatusOK, user) } +func getSettings(cfg *config.Config) func(echo.Context) error { + return func(c echo.Context) error { + settings := struct { + Auth struct { + Enabled bool + } + }{ + struct{ Enabled bool }{ + cfg.Auth.Enabled, + }, + } + + return c.JSON(http.StatusOK, settings) + } +} + func withMarshaler() runtime.ServeMuxOption { jsonpb := &gateway.JSONPb{ EmitDefaults: true, diff --git a/server/server.go b/server/server.go index f4721fe224..a8bf75ea1f 100644 --- a/server/server.go +++ b/server/server.go @@ -82,7 +82,7 @@ func NewServer(opts ...server_options.ServerOption) *Server { ))) conn := rpc.CreateFrontendGRPCConnection(serverOpts.Config.TemporalGRPCAddress) - routes.SetAPIRoutes(e, conn) + routes.SetAPIRoutes(e, serverOpts.Config, conn) routes.SetAuthRoutes(e, &serverOpts.Config.Auth) if serverOpts.Config.EnableOpenAPI {