Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var LoggerMiddleware = func(next http.Handler) http.Handler { c := alice.New( hlog.NewHandler(log.Logger), hlog.ProtoHandler("proto"), hlog.RequestHandler("url"), hlog.RemoteAddrHandler("ip"), hlog.UserAgentHandler("user_agent"), hlog.RequestIDHandler("req_id", "Request-Id"), hlog.AccessHandler(func(r *http.Request, status, size int, duration time.Duration) { hlog.FromRequest(r).Info(). Int("status", status). Int("size", size). Dur("duration", duration). Send() }), ) return c.Then(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { next.ServeHTTP(w, r) })) }
Functions ¶
Types ¶
type CircularQueue ¶ added in v0.4.0
type CircularQueue struct {
// contains filtered or unexported fields
}
small and simple implementation of a CircularQueue not thread safe
func (*CircularQueue) InQueue ¶ added in v0.4.0
func (q *CircularQueue) InQueue() uint8
func (*CircularQueue) Space ¶ added in v0.4.0
func (q *CircularQueue) Space() uint8
type CtxExpired ¶ added in v0.4.0
type CtxExpired string
func (CtxExpired) Error ¶ added in v0.4.0
func (CtxExpired) Error() string
type Handler ¶ added in v0.4.0
type Handler struct {
// contains filtered or unexported fields
}
func LoggerCtx_FromContext ¶ added in v0.4.2
func NewHandler ¶ added in v0.4.0
func NewHandler(w http.ResponseWriter, r *http.Request) *Handler
type LoggerCtx ¶ added in v0.4.2
var ResponseWithLogger LoggerCtx = func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { handler, logger, err := New(log.Logger, r, w) utils.Assert(err == nil, "could not create logger %s", err) r = r.WithContext(LoggerCtx_WithContex(r.Context(), logger, handler)) next.ServeHTTP(w, r) }) }
Click to show internal directories.
Click to hide internal directories.