Documentation ¶
Index ¶
- Constants
- func GetContextLogger(ctx context.Context) (*zap.Logger, error)
- func GetDomainName(ctx context.Context) string
- func GetRequestID(ctx context.Context) string
- func JSON(w http.ResponseWriter, v interface{})
- func NewPositionsResponse(domain string, positions []*db.Position) interface{}
- func NewSummaryResponse(domain string, positions int) interface{}
- func RequestLogger(log *zap.Logger) func(next http.Handler) http.Handler
- func RequireDomainName(next http.Handler) http.Handler
- func Routes(log *zap.Logger, b *backend.Backend) http.Handler
- func SetContextLogger(log *zap.Logger) func(next http.Handler) http.Handler
- func SetRequestID(log *zap.Logger) func(next http.Handler) http.Handler
Constants ¶
View Source
const ( RequestIDHeader = "x-request-id" RefererHeader = "referer" UserAgentHeader = "user-agent" XRealIPHeader = "x-real-ip" XForwardedForHeader = "x-forwarded-for" )
Variables ¶
This section is empty.
Functions ¶
func GetContextLogger ¶
GetContextLogger retrieves logger from the provided context.
func GetDomainName ¶
GetDomainName retrieves domain name value from context.
func GetRequestID ¶
GetRequestID gets a request ID from context or returns an empty string.
func JSON ¶
func JSON(w http.ResponseWriter, v interface{})
JSON marshals 'v' to JSON, automatically escaping HTML and setting the Content-Type as application/json. It will call http.Error in case of failures.
func NewPositionsResponse ¶
func NewSummaryResponse ¶
func RequestLogger ¶
RequestLogger handles logging of additional information about every request.
func RequireDomainName ¶
RequireDomainName middleware checks that 'domain' parameter is set and valid.
func SetContextLogger ¶
SetContextLogger populates additional field of the provided logger and saves it into context.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.