TokenInfoFromContext returns the [TokenInfo] stored in ctx, or nil if none.
(ctx context.Context)
| 53 | |
| 54 | // TokenInfoFromContext returns the [TokenInfo] stored in ctx, or nil if none. |
| 55 | func TokenInfoFromContext(ctx context.Context) *TokenInfo { |
| 56 | ti := ctx.Value(tokenInfoKey{}) |
| 57 | if ti == nil { |
| 58 | return nil |
| 59 | } |
| 60 | return ti.(*TokenInfo) |
| 61 | } |
| 62 | |
| 63 | // RequireBearerToken returns a piece of middleware that verifies a bearer token using the verifier. |
| 64 | // If verification succeeds, the [TokenInfo] is added to the request's context and the request proceeds. |