serve frontend from go

This commit is contained in:
u80864958
2025-05-05 10:00:50 +02:00
parent a06444c4df
commit 73a62b63ae
88 changed files with 76 additions and 36 deletions

22
internal/auth/ctx.go Normal file
View File

@ -0,0 +1,22 @@
package auth
import (
"context"
"net/http"
)
type authkey int
const keyClaims = iota
func writeToContext(r *http.Request, claims *Claims) *http.Request {
ctx := context.WithValue(r.Context(), keyClaims, claims)
return r.WithContext(ctx)
}
// ExtractClaims extracts user claims from given context. If no claims in context ok = false.
func ExtractClaims(ctx context.Context) (claims *Claims, ok bool) {
val := ctx.Value(keyClaims)
claims, ok = val.(*Claims)
return
}