Documentation ¶
Index ¶
- Constants
- func Decorate(roundTripper http.RoundTripper, decorators ...Decorator) http.RoundTripper
- func DecorateRoundTripper(conf config.Client, servConfig config.Server, accesslog log.Logger, ...) http.RoundTripper
- func NewHandlerWithRoundTripper(roundTripper http.RoundTripper, servConfig config.Server) (http.Handler, error)
- func OptionsHandler(roundTripper http.RoundTripper) http.RoundTripper
- type AccessMessageData
- type Decorator
- func AccessLogging(logger log.Logger) Decorator
- func AuthHeaderContextSuplementer() Decorator
- func BodySizeLimitter(bodySizeLimit int64) Decorator
- func HeadersSuplier(requestHeaders, responseHeaders config.AdditionalHeaders) Decorator
- func HealthCheckHandler(healthCheckEndpoint string) Decorator
- func PrivacyContextSupplier(supplier privacy.ContextSupplier) Decorator
- func PrivacyFilterChain(onErrorDrop, onValidationDrop bool, violationErrorCode int, ...) Decorator
- func RequestLimiter(maxConcurrentRequests int32) Decorator
- func ResponseHeadersStripper(headersToStrip []string) Decorator
- type Handler
- type SyncLogMessageData
Constants ¶
const ( //Domain is a constant used to put/get domain's name to/from request's context Domain = log.ContextKey("Domain") //AuthHeader is a constant used to put/get domain's name to/from request's context AuthHeader = log.ContextKey("AuthHeader") )
Variables ¶
This section is empty.
Functions ¶
func Decorate ¶
func Decorate(roundTripper http.RoundTripper, decorators ...Decorator) http.RoundTripper
Decorate returns http.Roundtripper wraped with all passed decorators
func DecorateRoundTripper ¶
func DecorateRoundTripper(conf config.Client, servConfig config.Server, accesslog log.Logger, healthCheckEndpoint string, rt http.RoundTripper) http.RoundTripper
DecorateRoundTripper applies common http.RoundTripper decorators
func NewHandlerWithRoundTripper ¶
func NewHandlerWithRoundTripper(roundTripper http.RoundTripper, servConfig config.Server) (http.Handler, error)
NewHandlerWithRoundTripper returns Handler, but will not construct transport.MultiTransport by itself
func OptionsHandler ¶
func OptionsHandler(roundTripper http.RoundTripper) http.RoundTripper
OptionsHandler changes OPTIONS method it to HEAD and pass it to decorated http.RoundTripper, also clears response content-length header
Types ¶
type AccessMessageData ¶
type AccessMessageData struct { Method string `json:"req_method"` Host string `json:"req_host"` Path string `json:"req_path"` UserAgent string `json:"req_useragent"` StatusCode int `json:"resp_status_code"` Duration float64 `json:"duration_ms"` RespErr string `json:"resp_err_msg"` ReqID string `json:"req_id"` Time string `json:"ts"` AccessKey string `json:"access_key"` BackendResponses string `json:"backend_responses"` }
AccessMessageData holds all important informations about http roundtrip
func NewAccessLogMessage ¶
func NewAccessLogMessage(req *http.Request, statusCode int, duration float64, respErr string) *AccessMessageData
NewAccessLogMessage creates new AccessMessageData
func ScanCSVAccessLogMessage ¶
func ScanCSVAccessLogMessage(csvstr string) (AccessMessageData, error)
ScanCSVAccessLogMessage will scan csv string and return AccessMessageData. Returns fmt.SScanf error if matching failed
func (AccessMessageData) String ¶
func (amd AccessMessageData) String() string
String produces data in csv format with fields in following order: Method, Host, Path, UserAgent, StatusCode, Duration, RespErr)
type Decorator ¶
type Decorator func(http.RoundTripper) http.RoundTripper
Decorator is http.RoundTripper interface wrapper
func AccessLogging ¶
AccessLogging creares Decorator with access log collector
func AuthHeaderContextSuplementer ¶
func AuthHeaderContextSuplementer() Decorator
AuthHeaderContextSuplementer adds utils.ParsedAuthorizationHeader to request context value
func BodySizeLimitter ¶
BodySizeLimitter rejects requests with to large body size
func HeadersSuplier ¶
func HeadersSuplier(requestHeaders, responseHeaders config.AdditionalHeaders) Decorator
HeadersSuplier creates Decorator which adds headers to request and response
func HealthCheckHandler ¶
HealthCheckHandler serving health check endpoint
func PrivacyContextSupplier ¶
func PrivacyContextSupplier(supplier privacy.ContextSupplier) Decorator
PrivacyContextSupplier creates Decorator which supplies the request with security context
func PrivacyFilterChain ¶
func PrivacyFilterChain(onErrorDrop, onValidationDrop bool, violationErrorCode int, chain privacy.Chain) Decorator
PrivacyFilterChain creates Decorator checks for any privacy violations
func RequestLimiter ¶
RequestLimiter limits number of concurrent requests
func ResponseHeadersStripper ¶
ResponseHeadersStripper creates Decorator which strips the Akubra specific headers
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements http.Handler interface
type SyncLogMessageData ¶
type SyncLogMessageData struct { Method string `json:"method"` FailedHost string `json:"failedhost"` Path string `json:"path"` SuccessHost string `json:"successhost"` UserAgent string `json:"useragent"` // ContentLength if negative means no content length header provided ContentLength int64 `json:"content-length"` AccessKey string `json:"access-key"` ErrorMsg string `json:"error"` ReqID string `json:"reqID"` Time string `json:"ts"` }
SyncLogMessageData holds all important informations about replication errors
func (SyncLogMessageData) String ¶
func (slmd SyncLogMessageData) String() string
String produces data in csv format with fields in following order: Method, Host, Path, UserAgent, StatusCode, Duration, RespErr)