From 557e1ec6d4bc5ad9eaff9e2e9548c1d1950069ed Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Sun, 15 Dec 2024 14:39:14 -0700 Subject: [PATCH] accept ?uuid=X instead of cookie --- cmd/server/server.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/server/server.go b/cmd/server/server.go index 6afce45..9bef28f 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -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