http

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 5 Imported by: 91

Documentation

Index

Constants

View Source
const RequestContextKey = requestContextKey(0)

RequestContextKey .

View Source
const (
	// SupportPackageIsVersion1 These constants should not be referenced from any other code.
	SupportPackageIsVersion1 = true
)

Variables

This section is empty.

Functions

func ContextRequest

func ContextRequest(ctx context.Context) *http.Request

ContextRequest .

func EncodeError

func EncodeError(w http.ResponseWriter, r *http.Request, err error)

EncodeError default EncodeErrorFunc implement

func WithRequest

func WithRequest(ctx context.Context, req *http.Request) context.Context

WithRequest .

Types

type DecodeRequestFunc

type DecodeRequestFunc func(*http.Request, interface{}) error

DecodeRequestFunc is decode request func.

type EncodeErrorFunc

type EncodeErrorFunc func(http.ResponseWriter, *http.Request, error)

EncodeErrorFunc is encode error func.

type EncodeResponseFunc

type EncodeResponseFunc func(http.ResponseWriter, *http.Request, interface{}) error

EncodeResponseFunc is encode response func.

type Error

type Error interface {
	HTTPStatus() int
}

Error .

type HandleOption

type HandleOption func(*HandleOptions)

HandleOption is handle option.

func WithDecoder

func WithDecoder(o DecodeRequestFunc) HandleOption

WithDecoder .

func WithEncoder

func WithEncoder(o EncodeResponseFunc) HandleOption

WithEncoder .

func WithErrorEncoder

func WithErrorEncoder(o EncodeErrorFunc) HandleOption

WithErrorEncoder .

func WithHTTPInterceptor

func WithHTTPInterceptor(i Interceptor) HandleOption

WithHTTPInterceptor .

func WithInterceptor

func WithInterceptor(o interceptor.Interceptor) HandleOption

WithInterceptor .

type HandleOptions

type HandleOptions struct {
	Decode          DecodeRequestFunc
	Encode          EncodeResponseFunc
	Error           EncodeErrorFunc
	Interceptor     interceptor.Interceptor
	HTTPInterceptor Interceptor
}

HandleOptions is handle options.

func DefaultHandleOptions

func DefaultHandleOptions() *HandleOptions

DefaultHandleOptions .

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request)

HandlerFunc .

type Interceptor

type Interceptor func(h http.HandlerFunc) http.HandlerFunc

Interceptor is the func to intercept request or response

type Router

type Router interface {
	Add(method, path string, handler HandlerFunc)
}

Router .

type RouterFunc

type RouterFunc func(method, path string, handler HandlerFunc)

RouterFunc .

func (RouterFunc) Add

func (fn RouterFunc) Add(method, path string, handler HandlerFunc)

Add .

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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