From 5b26634b8ae0ff09ab75e0747a49095f30617487 Mon Sep 17 00:00:00 2001 From: Haotian Date: Fri, 31 Mar 2023 13:09:48 -0700 Subject: [PATCH] feat(ui): serve controller metadata from ui handler (#3120) * adds noop metadata function to OSS UI handler * removes old-style build tags for UI handler files --- internal/daemon/controller/handler_ui.go | 9 +++++++-- internal/daemon/controller/handler_ui_test.go | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/daemon/controller/handler_ui.go b/internal/daemon/controller/handler_ui.go index a8de878f8..314c7c459 100644 --- a/internal/daemon/controller/handler_ui.go +++ b/internal/daemon/controller/handler_ui.go @@ -2,11 +2,11 @@ // SPDX-License-Identifier: MPL-2.0 //go:build ui -// +build ui package controller import ( + "context" "net/http" "strings" @@ -17,6 +17,9 @@ func init() { handleUi = handleUiWithAssets } +// serveMetadata provides controller metadata to the UI for licensed versions of Boundary. +var serveMetadata = func(ctx context.Context, w http.ResponseWriter) {} + func handleUiWithAssets(c *Controller) http.Handler { var nextHandler http.Handler if c.conf.RawConfig.DevUiPassthroughDir != "" { @@ -40,7 +43,9 @@ func handleUiWithAssets(c *Controller) http.Handler { default: switch r.URL.Path { case "/", "/favicon.png", "/assets/styles.css": - + case "/metadata.json": + serveMetadata(c.baseContext, w) + return default: for i := dotIndex + 1; i < len(r.URL.Path); i++ { intVal := r.URL.Path[i] diff --git a/internal/daemon/controller/handler_ui_test.go b/internal/daemon/controller/handler_ui_test.go index 4b927ca23..e59d43f2d 100644 --- a/internal/daemon/controller/handler_ui_test.go +++ b/internal/daemon/controller/handler_ui_test.go @@ -2,7 +2,6 @@ // SPDX-License-Identifier: MPL-2.0 //go:build ui -// +build ui package controller