diff --git a/internal/api/router.go b/internal/api/router.go index b96d3052..08eabff2 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -47,7 +47,7 @@ func (api *ApiManagerCtx) Route(r chi.Router) { r.Route("/room", roomHandler.Route) r.Get("/test", func(w http.ResponseWriter, r *http.Request) { - session, _ := r.Context().Value(keySessionCtx).(types.Session) + session := GetSession(r) utils.HttpBadRequest(w, "Hi `" + session.ID() + "`, you are authenticated.") }) } @@ -63,3 +63,7 @@ func (api *ApiManagerCtx) Authenticate(next http.Handler) http.Handler { } }) } + +func GetSession(r *http.Request) types.Session { + return r.Context().Value(keySessionCtx).(types.Session) +}