httputil

package
v0.0.0-...-e0434a4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessLog

func AccessLog(l AccessLogger) func(next http.Handler) http.Handler

func IsBadRequest

func IsBadRequest(err error) bool

func IsConflict

func IsConflict(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsServerError

func IsServerError(err error) bool

func IsUnknown

func IsUnknown(err error) bool

func NewBadRequest

func NewBadRequest(format string, v ...interface{}) error

func NewConflict

func NewConflict(format string, v ...interface{}) error

func NewNotFound

func NewNotFound(format string, v ...interface{}) error

func NewServerError

func NewServerError(code int, format string, v ...interface{}) error

func NewUnknown

func NewUnknown(format string, v ...interface{}) error

func WriteIntenalServerErrorResponse

func WriteIntenalServerErrorResponse(logger *zap.Logger, w http.ResponseWriter, err error)

func WriteNoContentResponse

func WriteNoContentResponse(logger *zap.Logger, w http.ResponseWriter)

func WriteOkResponse

func WriteOkResponse(logger *zap.Logger, w http.ResponseWriter, body []byte)

func WriteResponse

func WriteResponse(logger *zap.Logger, w http.ResponseWriter, responseCode int, body []byte)

Types

type AccessLogger

type AccessLogger interface {
	AccessLog(ctx context.Context, req AccessRequest, res AccessResponse, dur time.Duration)
}

type AccessRequest

type AccessRequest interface {
	RequestID() string
	RemoteAddr() string
	Proto() string
	Method() string
	RequestURI() string
	Host() string
	Referer() string
}

type AccessResponse

type AccessResponse interface {
	Status() int
	BytesWritten() int
}

type ClientError

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

func (*ClientError) Error

func (c *ClientError) Error() string

type ZapAccessLogger

type ZapAccessLogger struct {
	LogContextKey interface{}
}

func (*ZapAccessLogger) AccessLog

func (l *ZapAccessLogger) AccessLog(ctx context.Context, req AccessRequest, res AccessResponse, dur time.Duration)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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