server

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func ClientIP

func ClientIP(ctx context.Context) string

func ClientUserAgent

func ClientUserAgent(ctx context.Context) string

func ErrorFormatter added in v0.0.2

func ErrorFormatter() func(err error) (interface{}, error)

func HandleBlobs

func HandleBlobs(basePath string, cfg blob.Config, srv *khttp.Server, factory blob.Factory)

func HandlerWrap added in v0.0.2

func HandlerWrap[TRet any](resEncoder khttp.EncodeResponseFunc, handler HandlerFunc[TRet]) http.HandlerFunc

func IsAjax

func IsAjax(ctx context.Context) bool

func IsSecure

func IsSecure(ctx context.Context) bool

func IsWebsocket

func IsWebsocket(ctx context.Context) bool

func MiddlewareConvert

func MiddlewareConvert(errEncoder khttp.EncodeErrorFunc, m ...middleware.Middleware) func(handler http.Handler) http.Handler

func PatchFilter added in v0.0.2

func PatchFilter(logger klog.Logger, c *conf.Logging) klog.Logger

func PatchGrpcOpts

func PatchGrpcOpts(l log.Logger, opts []grpc.ServerOption, name string, services *conf.Services) []grpc.ServerOption

PatchGrpcOpts Patch grpc options with given service name and configs

func PatchHttpOpts

func PatchHttpOpts(l log.Logger,
	opts []khttp.ServerOption,
	name string,
	services *conf.Services,
	sCfg *conf.Security,
	reqDecoder khttp.DecodeRequestFunc,
	resEncoder khttp.EncodeResponseFunc,
	errEncoder khttp.EncodeErrorFunc,
	f ...khttp.FilterFunc) []khttp.ServerOption

PatchHttpOpts Patch khttp options with given service name and configs. f use global filters

func ResolveHttpRequest

func ResolveHttpRequest(ctx context.Context) (*http.Request, bool)

func Saas added in v0.0.2

func SetCookie

func SetCookie(ctx context.Context, value string) bool

Types

type DefaultErrorHandler

type DefaultErrorHandler struct {
	// contains filtered or unexported fields
}

func NewDefaultErrorHandler

func NewDefaultErrorHandler(errEncoder khttp.EncodeErrorFunc) *DefaultErrorHandler

func (*DefaultErrorHandler) Wrap

type ErrorHandler

type ErrorHandler interface {
	Wrap(func(w http.ResponseWriter, r *http.Request) error) http.Handler
}

type Handler added in v0.0.2

type Handler[TRet any] interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request) (TRet, error)
}

type HandlerFunc added in v0.0.2

type HandlerFunc[TRet any] func(w http.ResponseWriter, r *http.Request) (TRet, error)

Jump to

Keyboard shortcuts

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