Move the server daemons into their own package (#2061)
* Move the server daemons into their own package With this change the internal/server package now is dedicated to the server domain (workers and controllers) and not to the server daemons. The hope is that this will make it easier to keep the daemons decoupled from the representation of the servers in the database.
This commit is contained in:
177 files changed
+275
-275
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
)
|
||||
|
||||
func devUiPassthroughHandler(uiPassthroughDir string) http.Handler {
|
||||
const op = "controller.devPassthroughHandler"
|
||||
ctx := context.TODO()
|
||||
// Panic may not be ideal but this is never a production call and it'll
|
||||
// panic on startup. We could also just change the function to return
|
||||
// an error.
|
||||
abs, err := filepath.Abs(uiPassthroughDir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
event.WriteSysEvent(ctx, op, "serving passthrough files at /", "path", abs)
|
||||
fs := http.FileServer(http.Dir(abs))
|
||||
prefixHandler := http.StripPrefix("/", fs)
|
||||
|
||||
return prefixHandler
|
||||
}
|
||||
|
||||
var handleUi = func(c *Controller) http.Handler {
|
||||
if c.conf.RawConfig.DevUiPassthroughDir != "" {
|
||||
return devUiPassthroughHandler(c.conf.RawConfig.DevUiPassthroughDir)
|
||||
}
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user