httptransport

package
v1.0.0-beta.201 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorHandler

type ErrorHandler interface {
	HandleContext(ctx context.Context, err error)
}

ErrorHandler receives a transport error to be processed for diagnostic purposes. Usually this means logging the error.

type Handler

type Handler[Request any, Response any] interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request)
	Chain(outer operation.Middleware[Request, Response], others ...operation.Middleware[Request, Response]) Handler[Request, Response]
}

func NewHandler

func NewHandler[Request any, Response any](
	requestDecoder RequestDecoder[Request],
	op operation.Operation[Request, Response],
	responseEncoder encoder.ResponseEncoder[Response],

	options ...HandlerOption,
) Handler[Request, Response]

NewHandler returns a new HTTP handler that wraps the given operation.Operation.

type HandlerOption

type HandlerOption interface {
	// contains filtered or unexported methods
}

func AppendOptions

func AppendOptions(base []HandlerOption, items ...HandlerOption) []HandlerOption

func WithErrorEncoder

func WithErrorEncoder(errorEncoder encoder.ErrorEncoder) HandlerOption

func WithErrorHandler

func WithErrorHandler(errorHandler ErrorHandler) HandlerOption

func WithOperationName

func WithOperationName(name string) HandlerOption

func WithOperationNameFunc

func WithOperationNameFunc(fn func(ctx context.Context) string) HandlerOption

type HandlerWithArgs

type HandlerWithArgs[Request any, Response any, ArgType any] interface {
	With(ArgType) Handler[Request, Response]
	Chain(outer operation.Middleware[Request, Response], others ...operation.Middleware[Request, Response]) HandlerWithArgs[Request, Response, ArgType]
}

func NewHandlerWithArgs

func NewHandlerWithArgs[Request any, Response any, ArgType any](
	requestDecoder RequestDecoderWithArgs[Request, ArgType],
	op operation.Operation[Request, Response],
	responseEncoder encoder.ResponseEncoder[Response],

	options ...HandlerOption,
) HandlerWithArgs[Request, Response, ArgType]

type RequestDecoder

type RequestDecoder[Request any] func(ctx context.Context, r *http.Request) (Request, error)

type RequestDecoderWithArgs

type RequestDecoderWithArgs[Request any, ArgType any] func(ctx context.Context, r *http.Request, arg ArgType) (Request, error)

type SelfEncodingError

type SelfEncodingError interface {
	EncodeError(ctx context.Context, w http.ResponseWriter) bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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