v1

package
v0.0.0-...-41663d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

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

func GetContextLogger(ctx context.Context) (*zap.Logger, error)

GetContextLogger retrieves logger from the provided context.

func GetDomainName

func GetDomainName(ctx context.Context) string

GetDomainName retrieves domain name value from context.

func GetRequestID

func GetRequestID(ctx context.Context) string

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 NewPositionsResponse(domain string, positions []*db.Position) interface{}

func NewSummaryResponse

func NewSummaryResponse(domain string, positions int) interface{}

func RequestLogger

func RequestLogger(log *zap.Logger) func(next http.Handler) http.Handler

RequestLogger handles logging of additional information about every request.

func RequireDomainName

func RequireDomainName(next http.Handler) http.Handler

RequireDomainName middleware checks that 'domain' parameter is set and valid.

func Routes

func Routes(log *zap.Logger, b *backend.Backend) http.Handler

Routes initializes v1 handler.

func SetContextLogger

func SetContextLogger(log *zap.Logger) func(next http.Handler) http.Handler

SetContextLogger populates additional field of the provided logger and saves it into context.

func SetRequestID

func SetRequestID(log *zap.Logger) func(next http.Handler) http.Handler

SetRequestID middleware creates a new request ID and saves it into request context.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL