http

package
v0.0.0-...-9146478 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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