accept ?uuid=X instead of cookie

main
Bel LaPointe 2024-12-15 14:39:14 -07:00
parent 3095d54f99
commit 557e1ec6d4
1 changed files with 9 additions and 3 deletions

View File

@ -59,13 +59,19 @@ type Session struct {
}
func (s *S) injectContext(w http.ResponseWriter, r *http.Request) error {
id, err := r.Cookie("uuid")
if err != nil || id.Value == "" {
id := r.Header.Get("uuid")
if id == "" {
c, _ := r.Cookie("uuid")
if c != nil {
id = c.Value
}
}
if id == "" {
return io.EOF
}
ctx := r.Context()
ctx = context.WithValue(ctx, "session", Session{
ID: id.Value,
ID: id,
})
*r = *r.WithContext(ctx)
return nil