Documentation ¶
Index ¶
- Constants
- func Auth(token auth.Token) func(http.Handler) http.Handler
- func AuthOptional(token auth.Token) func(http.Handler) http.Handler
- func GetClaimsFromContext(ctx context.Context) auth.Claim
- func GetDBConnFromContext(ctx context.Context) *sql.DB
- func GetDBFromContext[T any](ctx context.Context, f func(*sql.DB) T) T
- func GetDefaultLogger(serviceName, environment string, level int) *logrus.Entry
- func GetInsecureUserIDFromContext(ctx context.Context) string
- func GetLoggerFromContext(ctx context.Context) *logrus.Entry
- func GetRequestIDFromContext(ctx context.Context) string
- func GetStack(skip int) []byte
- func HandlerFunc(h func(w http.ResponseWriter, r *http.Request) error) http.Handler
- func NoCache(h http.Handler) http.Handler
- func Recovery(h http.Handler) http.Handler
- func RequestID(h http.Handler) http.Handler
- type JWTDecoder
- type Logger
- type Timer
- type UserIDIngector
Constants ¶
const (
HeaderRequestID = "x-request-id"
)
Variables ¶
This section is empty.
Functions ¶
func AuthOptional ¶
Attempts to get the auth token from the HTTP Authorization header, decrypt it, and place it on the context, but allows requests through even if they don't have this header field
func GetDefaultLogger ¶
GetDefaultLogger gets a default logger to use. level is a number from 0-7, 0 being the most strict and 7 the most verbose
func GetInsecureUserIDFromContext ¶
getInsecureUserIDFromContext returns the user id or empty string if missing
func GetLoggerFromContext ¶
GetLoggerFromContext returns a logrus entry from the context, defaulting to a standard one if its not found
func GetRequestIDFromContext ¶
GetRequestIDFromContext returns the requestID or empty string if missing
func HandlerFunc ¶
HandlerFunc converts a handler with an error to a standard handler
Types ¶
type JWTDecoder ¶
type Timer ¶
type Timer interface {
Time(name string) alice.Constructor
}
Timer can time a handler and log it
func NewNullTimer ¶
func NewNullTimer() Timer
type UserIDIngector ¶
UserIDIngector injects a UserID from a JWT into the context
func NewUserIDInjector ¶
func NewUserIDInjector(jwt JWTDecoder) UserIDIngector
NewLogrusLogger allows you to setup a base entry to use for logging