Rework request context handler

This commit is contained in:
2024-11-03 19:17:10 +01:00
parent dfd9544fba
commit c8cc854fd6
14 changed files with 217 additions and 217 deletions

View File

@@ -5,6 +5,8 @@ import (
"fmt"
"net/http"
"strings"
"novamd/internal/httpcontext"
)
type contextKey string
@@ -95,9 +97,8 @@ func (m *Middleware) RequireRole(role string) func(http.Handler) http.Handler {
func (m *Middleware) RequireWorkspaceAccess(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Get our handler context
ctx := context.GetHandlerContext(r)
if ctx == nil {
http.Error(w, "Internal server error", http.StatusInternalServerError)
ctx, ok := httpcontext.GetRequestContext(w, r)
if !ok {
return
}