oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package identity
2
3import (
4 "amadan.net/rastrillo/rastrillo/auth"
5 "context"
6 "net/http"
7)
8
9type key struct{}
10
11func With(r *http.Request, id auth.Identity) *http.Request {
12 return r.WithContext(context.WithValue(r.Context(), key{}, id))
13}
14func From(r *http.Request) (auth.Identity, bool) {
15 if id, ok := r.Context().Value(key{}).(auth.Identity); ok {
16 return id, true
17 }
18 return auth.From(r)
19}
20