Documentation
¶
Index ¶
- Constants
- func GetClientIP(ctx context.Context) (netip.Addr, bool)
- func GetUserAuthFromContext(ctx context.Context) (auth.UserAuth, error)
- func GetUserAuthFromRequest(r *http.Request) (auth.UserAuth, error)
- func RoleFromContext(ctx context.Context) (string, bool)
- func SetClientIP(ctx context.Context, ip netip.Addr) context.Context
- func SetUserAuthInContext(ctx context.Context, userAuth auth.UserAuth) context.Context
- func SetUserAuthInRequest(r *http.Request, userAuth auth.UserAuth) *http.Request
- func WithRole(ctx context.Context, role string) context.Context
Constants ¶
const ( RequestIDKey = nbcontext.RequestIDKey AccountIDKey = nbcontext.AccountIDKey RoleKey = nbcontext.RoleKey UserIDKey = nbcontext.UserIDKey PeerIDKey = nbcontext.PeerIDKey UserAgentKey = nbcontext.UserAgentKey )
const (
UserAuthContextKey key = iota
)
Variables ¶
This section is empty.
Functions ¶
func GetClientIP ¶ added in v0.84.0
GetClientIP returns the client IP stored in ctx, or false if none is set or it is invalid.
func GetUserAuthFromContext ¶ added in v0.37.0
func GetUserAuthFromRequest ¶ added in v0.37.0
func RoleFromContext ¶ added in v0.72.0
RoleFromContext returns the role stored in ctx, or empty string and false if absent.
func SetClientIP ¶ added in v0.84.0
SetClientIP returns a new context carrying the resolved client IP of the request.
func SetUserAuthInContext ¶ added in v0.37.0
func SetUserAuthInRequest ¶ added in v0.37.0
Types ¶
This section is empty.