httphandler

package
v0.0.0-...-998cc21 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 NewHandler

func NewHandler(conf config.Config) http.Handler

NewHandler will create Handler

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:"method"`
	Host       string  `json:"host"`
	Path       string  `json:"path"`
	UserAgent  string  `json:"useragent"`
	StatusCode int     `json:"status"`
	Duration   float64 `json:"duration"`
	RespErr    string  `json:"error"`
	Time       string  `json:"ts"`
}

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

func AccessLogging(logger *log.Logger) Decorator

AccessLogging creares Decorator with access log collector

func HeadersSuplier

func HeadersSuplier(requestHeaders, responseHeaders map[string]string) Decorator

HeadersSuplier creates Decorator which adds headers to request and response

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler implements http.Handler interface

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)

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"`
	ErrorMsg    string `json:"error"`
	Time        string `json:"ts"`
}

SyncLogMessageData holds all important informations about replication errors

func NewSyncLogMessageData

func NewSyncLogMessageData(method, failedHost, path, successHost, userAgent,
	errorMsg string) *SyncLogMessageData

NewSyncLogMessageData creates new SyncLogMessageData

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)

Jump to

Keyboard shortcuts

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