UserParam returns the user from the ExtractUserParam handler.
(r *http.Request)
| 24 | |
| 25 | // UserParam returns the user from the ExtractUserParam handler. |
| 26 | func UserParam(r *http.Request) database.User { |
| 27 | user, ok := r.Context().Value(userParamContextKey{}).(database.User) |
| 28 | if !ok { |
| 29 | panic("developer error: user parameter middleware not provided") |
| 30 | } |
| 31 | return user |
| 32 | } |
| 33 | |
| 34 | func UserParamOptional(r *http.Request) (database.User, bool) { |
| 35 | user, ok := r.Context().Value(userParamContextKey{}).(database.User) |