Improve response logger and fix '/' route
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4507728dae
commit
20fde2335e
6 changed files with 43 additions and 31 deletions
|
@ -23,12 +23,14 @@ func (sc *StaticController) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
type IndexController struct {
|
||||
l *logrus.Logger
|
||||
l *logrus.Logger
|
||||
downstreamConstroller http.Handler
|
||||
}
|
||||
|
||||
func NewIndexController(l *logrus.Logger) *IndexController {
|
||||
func NewIndexController(l *logrus.Logger, downstream http.Handler) *IndexController {
|
||||
return &IndexController{
|
||||
l: l,
|
||||
l: l,
|
||||
downstreamConstroller: downstream,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,8 +55,7 @@ func (ic IndexController) serveUI(w http.ResponseWriter, r *http.Request) (int,
|
|||
|
||||
func (ic *IndexController) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if r.RequestURI != "/" {
|
||||
ic.l.Errorf("Unhandled route %q", r.RequestURI)
|
||||
helpers.HandleResponse(w, r, http.StatusNotFound, nil, ic.l)
|
||||
ic.downstreamConstroller.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
returncode, contentLength, err := ic.serveUI(w, r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue