courierhttp

package
v0.0.0-...-58f8293 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 14 Imported by: 5

Documentation

Overview

+gengo:runtimedoc=false

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasePath

func BasePath(basePath string) courier.Operator

func BasePathRouter

func BasePathRouter(basePath string) courier.Router

func ContextWithErrResponseWriter

func ContextWithErrResponseWriter(ctx context.Context, errResponseWriter ErrResponseWriter) context.Context

func ContextWithHttpRequest

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

func ContextWithOperationInfo

func ContextWithOperationInfo(ctx context.Context, info OperationInfo) context.Context

func ContextWithRouteDescriber

func ContextWithRouteDescriber(ctx context.Context, r RouteDescriber) context.Context

func Group

func Group(path string) courier.Operator

func GroupRouter

func GroupRouter(path string) courier.Router

func HttpRequestFromContext

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

func WrapReadCloser

func WrapReadCloser(r io.Reader) io.ReadCloser

Types

type BasePathDescriber

type BasePathDescriber interface {
	BasePath() string
}

type ContentTypeDescriber

type ContentTypeDescriber interface {
	ContentType() string
}

type CookiesDescriber

type CookiesDescriber interface {
	Cookies() []*http.Cookie
}

type ErrResponseWriter

type ErrResponseWriter interface {
	WriteErr(ctx context.Context, rw http.ResponseWriter, req Request, statusErr *statuserror.StatusErr)
}

func ErrResponseWriterFromContext

func ErrResponseWriterFromContext(ctx context.Context) ErrResponseWriter

func ErrResponseWriterFunc

func ErrResponseWriterFunc(fn func(ctx context.Context, rw http.ResponseWriter, req Request, statusErr *statuserror.StatusErr)) ErrResponseWriter

type ErrorResponse

func WrapError

func WrapError(err error, opts ...ResponseSettingFunc) ErrorResponse

type FileHeader

type FileHeader interface {
	io.ReadCloser

	Filename() string
	Header() http.Header
}

type Method

type Method struct {
}

type MethodConnect

type MethodConnect struct{}

func (MethodConnect) Method

func (MethodConnect) Method() string

type MethodDelete

type MethodDelete struct{}

func (MethodDelete) Method

func (MethodDelete) Method() string

type MethodDescriber

type MethodDescriber interface {
	Method() string
}

type MethodGet

type MethodGet struct{}

func (MethodGet) Method

func (MethodGet) Method() string

type MethodHead

type MethodHead struct{}

func (MethodHead) Method

func (MethodHead) Method() string

type MethodOptions

type MethodOptions struct{}

func (MethodOptions) Method

func (MethodOptions) Method() string

type MethodPatch

type MethodPatch struct{}

func (MethodPatch) Method

func (MethodPatch) Method() string

type MethodPost

type MethodPost struct{}

func (MethodPost) Method

func (MethodPost) Method() string

type MethodPut

type MethodPut struct{}

func (MethodPut) Method

func (MethodPut) Method() string

type MethodTrace

type MethodTrace struct{}

func (MethodTrace) Method

func (MethodTrace) Method() string

type OperationInfo

type OperationInfo struct {
	Server
	ID     string
	Method string
	Route  string
}

func OperationInfoFromContext

func OperationInfoFromContext(ctx context.Context) OperationInfo

func (OperationInfo) UserAgent

func (s OperationInfo) UserAgent() string

type PathDescriber

type PathDescriber interface {
	Path() string
}

type RedirectDescriber

type RedirectDescriber interface {
	StatusCodeDescriber
	Location() *url.URL
}

type Request

type Request interface {
	Context() context.Context

	ServiceName() string

	Method() string
	Path() string
	Header() http.Header
	Values(in string, name string) []string
	Body() io.ReadCloser

	Underlying() *http.Request
}

type Response

func Redirect

func Redirect(statusCode int, location *url.URL) Response[any]

func Wrap

func Wrap[T any](v T, opts ...ResponseSettingFunc) Response[T]

type ResponseSetting

type ResponseSetting interface {
	SetStatusCode(statusCode int)
	SetLocation(location *url.URL)
	SetContentType(contentType string)
	SetMetadata(key string, values ...string)
	SetCookies(cookies []*http.Cookie)
}

type ResponseSettingFunc

type ResponseSettingFunc = func(s ResponseSetting)

func WithContentType

func WithContentType(contentType string) ResponseSettingFunc

func WithCookies

func WithCookies(cookies ...*http.Cookie) ResponseSettingFunc

func WithMetadata

func WithMetadata(key string, values ...string) ResponseSettingFunc

func WithStatusCode

func WithStatusCode(statusCode int) ResponseSettingFunc

type ResponseWriter

type ResponseWriter interface {
	WriteResponse(ctx context.Context, rw http.ResponseWriter, req Request) error
}

type RouteDescriber

type RouteDescriber interface {
	MethodDescriber
	PathDescriber
}

func RouteDescriberFromContext

func RouteDescriberFromContext(ctx context.Context) RouteDescriber

type Server

type Server struct {
	Name    string
	Version string
}

func (Server) UserAgent

func (s Server) UserAgent() string

type StatusCodeDescriber

type StatusCodeDescriber interface {
	StatusCode() int
}

type Transformer

type Transformer interface {
	// Names name or alias of transformer
	// prefer using some keyword about content-type
	Names() []string

	// New transformer instance by type
	// in this step will to check transformer is valid for type
	New(context.Context, typesutil.Type) (Transformer, error)

	// EncodeTo writer
	EncodeTo(w io.Writer, v any) (mediaType string, err error)

	// DecodeFrom reader
	DecodeFrom(r io.Reader, v any, headers ...textproto.MIMEHeader) error
}

type WithHeader

type WithHeader interface {
	Header() http.Header
}

Directories

Path Synopsis
Package client GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
Package client GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
Package handler GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
Package handler GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
httprouter
Package httprouter GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
Package httprouter GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
Package openapi GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
Package openapi GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE

Jump to

Keyboard shortcuts

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