accept ?uuid=X instead of cookie
parent
3095d54f99
commit
557e1ec6d4
|
|
@ -59,13 +59,19 @@ type Session struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *S) injectContext(w http.ResponseWriter, r *http.Request) error {
|
func (s *S) injectContext(w http.ResponseWriter, r *http.Request) error {
|
||||||
id, err := r.Cookie("uuid")
|
id := r.Header.Get("uuid")
|
||||||
if err != nil || id.Value == "" {
|
if id == "" {
|
||||||
|
c, _ := r.Cookie("uuid")
|
||||||
|
if c != nil {
|
||||||
|
id = c.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if id == "" {
|
||||||
return io.EOF
|
return io.EOF
|
||||||
}
|
}
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
ctx = context.WithValue(ctx, "session", Session{
|
ctx = context.WithValue(ctx, "session", Session{
|
||||||
ID: id.Value,
|
ID: id,
|
||||||
})
|
})
|
||||||
*r = *r.WithContext(ctx)
|
*r = *r.WithContext(ctx)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue