Enable requests logging for the worker.

Code is still duplicated. Will search for a solution later.
This commit is contained in:
ErickSkrauch 2020-04-15 16:01:30 +03:00
parent b0ba94751a
commit c9f6079d90
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E

View File

@ -20,11 +20,18 @@ type UUIDsWorker struct {
}
func (ctx *UUIDsWorker) CreateHandler() *mux.Router {
requestEventsMiddleware := CreateRequestEventsMiddleware(ctx.Emitter, "skinsystem")
router := mux.NewRouter().StrictSlash(true)
router.NotFoundHandler = http.HandlerFunc(NotFound)
router.Use(requestEventsMiddleware)
router.Handle("/api/worker/mojang-uuid/{username}", http.HandlerFunc(ctx.GetUUID)).Methods("GET")
// 404
// NotFoundHandler doesn't call for registered middlewares, so we must wrap it manually.
// See https://github.com/gorilla/mux/issues/416#issuecomment-600079279
router.NotFoundHandler = requestEventsMiddleware(http.HandlerFunc(NotFound))
return router
}