handler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSourceEvent

func GetSourceEvent(ctx context.Context) any

func NewHandler

func NewHandler[In any, W http.ResponseWriter, Out any](reqConverter RequestConverterFunc[In], resInitializer ResponseInitializerFunc[W], resFinalizer ResponseFinalizerFunc[W, Out], adapter AdapterFunc) func(context.Context, In) (Out, error)

func WithSourceEvent

func WithSourceEvent(ctx context.Context, event any) context.Context

func WrapWithRecover

func WrapWithRecover[In any, Out any](handler func(context.Context, In) (Out, error), recoverFunc RecoverFunc[In, Out]) func(context.Context, In) (Out, error)

Types

type AdapterFunc

type AdapterFunc func(ctx context.Context, r *http.Request, w http.ResponseWriter) error

type RecoverFunc

type RecoverFunc[In any, Out any] func(ctx context.Context, event In, panicValue any) (Out, error)

type RequestConverterFunc

type RequestConverterFunc[In any] func(ctx context.Context, event In) (*http.Request, error)

type ResponseFinalizerFunc

type ResponseFinalizerFunc[W http.ResponseWriter, Out any] func(ctx context.Context, w W) (Out, error)

type ResponseInitializerFunc

type ResponseInitializerFunc[W http.ResponseWriter] func(ctx context.Context) W

type ResponseWriterProxy

type ResponseWriterProxy struct {
	Status  int
	Headers http.Header
	Body    bytes.Buffer
}

func NewResponseWriterProxy

func NewResponseWriterProxy() *ResponseWriterProxy

func (*ResponseWriterProxy) Header

func (w *ResponseWriterProxy) Header() http.Header

func (*ResponseWriterProxy) Write

func (w *ResponseWriterProxy) Write(p []byte) (int, error)

func (*ResponseWriterProxy) WriteHeader

func (w *ResponseWriterProxy) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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