added not found and method not allowed handler for debugging

This commit is contained in:
overflowerror 2021-08-15 16:02:25 +02:00
parent d122924fde
commit bd726f484d
2 changed files with 11 additions and 0 deletions

View file

@ -11,6 +11,7 @@ import (
func ctxWrapper(appCtx *app.Context, handler web.Handler) httprouter.Handle {
return func(writer http.ResponseWriter, request *http.Request, params httprouter.Params) {
writer.Header().Add("Content-Type", "application/json")
start := time.Now()
handler(&web.Context{
Response: writer,

View file

@ -10,6 +10,16 @@ import (
func Setup(ctx *app.Context) http.Handler {
router := &router{Router: httprouter.New(), appCtx: ctx}
router.NotFound = http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
ctx.AccessLog.Printf("%s %s; not found", request.Method, request.URL.String())
writer.WriteHeader(http.StatusNotFound)
})
router.MethodNotAllowed = http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
ctx.AccessLog.Printf("%s %s; method not allowed", request.Method, request.URL.String())
writer.WriteHeader(http.StatusMethodNotAllowed)
})
router.POST("/authentication", Login)
router.GET("/authentication", authenticated(GetAuthenticationData))