added staging banner
This commit is contained in:
@@ -44,17 +44,21 @@ func addMiddleware(
|
||||
func devMode(cfg *config.Config) hws.Middleware {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if cfg.Flags.DevMode {
|
||||
devInfo := contexts.DevInfo{
|
||||
WebsocketBase: "ws://" + cfg.HWS.Host + ":" + strconv.FormatUint(cfg.HWS.Port, 10),
|
||||
HTMXLog: true,
|
||||
}
|
||||
ctx := context.WithValue(r.Context(), contexts.DevModeKey, devInfo)
|
||||
req := r.WithContext(ctx)
|
||||
next.ServeHTTP(w, req)
|
||||
if !cfg.Flags.DevMode && !cfg.Flags.Staging {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
devInfo := contexts.DevInfo{}
|
||||
if cfg.Flags.DevMode {
|
||||
devInfo.WebsocketBase = "ws://" + cfg.HWS.Host + ":" + strconv.FormatUint(cfg.HWS.Port, 10)
|
||||
devInfo.HTMXLog = true
|
||||
}
|
||||
if cfg.Flags.Staging {
|
||||
devInfo.StagingBanner = true
|
||||
}
|
||||
ctx := context.WithValue(r.Context(), contexts.DevModeKey, devInfo)
|
||||
req := r.WithContext(ctx)
|
||||
next.ServeHTTP(w, req)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user