http

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SafeMethods = []string{"GET", "HEAD", "OPTIONS", "TRACE"}
)

Functions

func Uow

func Uow(mgr uow.Manager, handler HandlerFunc, opts ...Option) http.Handler

Uow wrap HandlerFunc with unit of work

Types

type EncodeErrorFunc

type EncodeErrorFunc func(http.ResponseWriter, *http.Request, error)

EncodeErrorFunc how to encode error when a unit of work rollback

type HandlerFunc

type HandlerFunc func(w http.ResponseWriter, r *http.Request) error

type Option

type Option func(*option)

func WithErrorEncoder

func WithErrorEncoder(f EncodeErrorFunc) Option

WithErrorEncoder error encoder. default will not encode any error

func WithSkip

func WithSkip(f SkipFunc) Option

WithSkip change the skip unit of work function. default will skip SafeMethods like "GET", "HEAD", "OPTIONS", "TRACE"

func WithTxOpt

func WithTxOpt(txOpt ...*sql.TxOptions) Option

type SkipFunc

type SkipFunc func(r *http.Request) bool

SkipFunc identity whether a request should skip run into unit of work

Jump to

Keyboard shortcuts

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