pkghttp

package
v0.0.0-...-d025c41 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeResponse

func EncodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error

func ErrorEncoder

func ErrorEncoder(_ context.Context, err error, w http.ResponseWriter)

func NewServer

func NewServer(options ...ServerOption) *server

Types

type ContextFn

type ContextFn func(ctx context.Context, r Request) context.Context

type EndpointFn

type EndpointFn func(ctx context.Context, r Request) (response interface{}, err error)

type EndpointMiddlewareFn

type EndpointMiddlewareFn func(next EndpointFn) EndpointFn

type EndpointOption

type EndpointOption interface {
	Apply(*endpoint)
}

func WithContext

func WithContext(ContextFn ContextFn) EndpointOption

func WithPreRequestMiddleware

func WithPreRequestMiddleware(mds ...EndpointMiddlewareFn) EndpointOption

type EndpointOptionFn

type EndpointOptionFn func(*endpoint)

func (EndpointOptionFn) Apply

func (o EndpointOptionFn) Apply(e *endpoint)

type ErrorResponseEncoderFn

type ErrorResponseEncoderFn func(ctx context.Context, err error, w http.ResponseWriter)

type Headerer

type Headerer interface {
	Headers() http.Header
}

type Request

type Request interface {
	AddCookie(c *http.Cookie)
	BasicAuth() (username string, password string, ok bool)
	Clone(ctx context.Context) *http.Request
	Context() context.Context
	Cookie(name string) (*http.Cookie, error)
	Cookies() []*http.Cookie
	FormFile(key string) (multipart.File, *multipart.FileHeader, error)
	FormValue(key string) string
	MultipartReader() (*multipart.Reader, error)
	ParseForm() error
	ParseMultipartForm(maxMemory int64) error
	PostFormValue(key string) string
	ProtoAtLeast(major int, minor int) bool
	Referer() string
	SetBasicAuth(username string, password string)
	UserAgent() string
	WithContext(ctx context.Context) *http.Request
	Write(w io.Writer) error
	WriteProxy(w io.Writer) error

	Body() io.ReadCloser
	Decode(v any) error
	Header() http.Header
	URL() *url.URL
}

type ResponseEncoderFn

type ResponseEncoderFn func(ctx context.Context, w http.ResponseWriter, response interface{}) error

type ServerOption

type ServerOption interface {
	Apply(*server)
}

func WithErrorResponseEncoder

func WithErrorResponseEncoder(e ErrorResponseEncoderFn) ServerOption

func WithResponseEncoder

func WithResponseEncoder(e ResponseEncoderFn) ServerOption

type ServerOptionFn

type ServerOptionFn func(*server)

func (ServerOptionFn) Apply

func (o ServerOptionFn) Apply(s *server)

type StatusCoder

type StatusCoder interface {
	StatusCode() int
}

Directories

Path Synopsis
v1

Jump to

Keyboard shortcuts

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