server

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 29 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AuthzGuardian

func AuthzGuardian(srv authz.Service, requirement authz.RequirementList, encoder khttp.EncodeErrorFunc, handler http.Handler) http.Handler

AuthzGuardian guard http.Handler with authz

func ClientIP

func ClientIP(ctx context.Context) string

func ClientUserAgent

func ClientUserAgent(ctx context.Context) string

func HandleBlobs

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

func HandlerWrap

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

func Host

func Host(ctx context.Context) string

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

MiddlewareConvert convert kratos middleware into standard http middleware

func NewRegistrar

func NewRegistrar(services *conf.Services) (registry.Registrar, error)

func NewWebMultiTenancyOption

func NewWebMultiTenancyOption(opt *conf.AppConfig) *shttp.WebMultiTenancyOption

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 Recovery

func Recovery() middleware.Middleware

Recovery wrap kratos recovery with handler

func ResolveHttpRequest

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

func Saas

func Saas(hmtOpt *shttp.WebMultiTenancyOption, ts saas.TenantStore, trustedContextValidator api.TrustedContextValidator, options ...saas.ResolveOption) middleware.Middleware

Types

type GrpcServiceRegister

type GrpcServiceRegister interface {
	Register(server *grpc.Server, middleware ...middleware.Middleware)
}

GrpcServiceRegister register grpc handler into grpc server

func ChainGrpcServiceRegister

func ChainGrpcServiceRegister(r ...GrpcServiceRegister) GrpcServiceRegister

type GrpcServiceRegisterFunc

type GrpcServiceRegisterFunc func(server *grpc.Server, middleware ...middleware.Middleware)

func (GrpcServiceRegisterFunc) Register

func (f GrpcServiceRegisterFunc) Register(server *grpc.Server, middleware ...middleware.Middleware)

type Handler

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

type HandlerFunc

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

type HttpServiceRegister

type HttpServiceRegister interface {
	Register(server *khttp.Server, middleware ...middleware.Middleware)
}

HttpServiceRegister register http handler into http server

func ChainHttpServiceRegister

func ChainHttpServiceRegister(r ...HttpServiceRegister) HttpServiceRegister

type HttpServiceRegisterFunc

type HttpServiceRegisterFunc func(server *khttp.Server, middleware ...middleware.Middleware)

func (HttpServiceRegisterFunc) Register

func (f HttpServiceRegisterFunc) Register(server *khttp.Server, middleware ...middleware.Middleware)

Jump to

Keyboard shortcuts

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