mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-10 15:01:03 +00:00
Merge pull request #1417 from ajnavarro/fix-log-web-ui-http-handler
This commit is contained in:
commit
2089e5eeb4
3 changed files with 10 additions and 4 deletions
|
|
@ -67,6 +67,8 @@ type Handler struct {
|
|||
api *pilosa.API
|
||||
|
||||
ln net.Listener
|
||||
// url is used to hold the advertise bind address for printing a log during startup.
|
||||
url string
|
||||
|
||||
closeTimeout time.Duration
|
||||
|
||||
|
|
@ -135,9 +137,13 @@ func OptHandlerLogger(logger logger.Logger) handlerOption {
|
|||
}
|
||||
}
|
||||
|
||||
func OptHandlerListener(ln net.Listener) handlerOption {
|
||||
// OptHandlerListener set the listener that will be used by the HTTP server.
|
||||
// Url must be the advertised URL. It will be used to show a log to the user
|
||||
// about where the Web UI is. This option is mandatory.
|
||||
func OptHandlerListener(ln net.Listener, url string) handlerOption {
|
||||
return func(h *Handler) error {
|
||||
h.ln = ln
|
||||
h.url = url
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -502,7 +508,7 @@ type statikHandler struct {
|
|||
func newStatikHandler(h *Handler) statikHandler {
|
||||
fs, err := h.fileSystem.New()
|
||||
if err == nil {
|
||||
h.logger.Printf("enabled Web UI (%s) at %s", h.api.LatticeVersion(), h.ln.Addr().String())
|
||||
h.logger.Printf("enabled Web UI (%s) at %s", h.api.LatticeVersion(), h.url)
|
||||
}
|
||||
|
||||
return statikHandler{
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ func TestHandlerOptions(t *testing.T) {
|
|||
return err
|
||||
}, 10)
|
||||
|
||||
_, err = http.NewHandler(http.OptHandlerListener(ln))
|
||||
_, err = http.NewHandler(http.OptHandlerListener(ln, ln.Addr().String()))
|
||||
if err == nil {
|
||||
t.Fatalf("expected error making handler without options, got nil")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ func (m *Command) SetupServer() error {
|
|||
http.OptHandlerAPI(m.API),
|
||||
http.OptHandlerLogger(m.logger),
|
||||
http.OptHandlerFileSystem(&statik.FileSystem{}),
|
||||
http.OptHandlerListener(m.ln),
|
||||
http.OptHandlerListener(m.ln, m.Config.Advertise),
|
||||
http.OptHandlerCloseTimeout(m.closeTimeout),
|
||||
http.OptHandlerMiddleware(m.grpcServer.middleware(m.Config.Handler.AllowedOrigins)),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue