Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions server/routes/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down