http

package
v0.0.5-0...-8e55a6f Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AuthnGuardian

func AuthnGuardian(encoder khttp.EncodeErrorFunc, handler http.Handler) http.Handler

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 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 MountBlob

func MountBlob(srv *khttp.Server, pathPrefix, basePath string, b vfs.Blob)

func PatchOpts

func PatchOpts(l log.Logger,
	opts []khttp.ServerOption,
	server *conf.Server,
	sCfg *conf.Security,
	reqDecoder khttp.DecodeRequestFunc,
	resEncoder khttp.EncodeResponseFunc,
	errEncoder khttp.EncodeErrorFunc,
	f ...khttp.FilterFunc) []khttp.ServerOption

PatchOpts Patch http options with given service name and configs. f use global filters

func ResolveHttpRequest

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

func SetCookie

func SetCookie(ctx context.Context, cookie *http.Cookie) error

Types

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 Server

type Server struct {
	*khttp.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg *conf.Server, opts ...khttp.ServerOption) *Server

func (*Server) Endpoint

func (s *Server) Endpoint() (url *url.URL, err error)

type ServiceRegister

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

ServiceRegister register http handler into http server

func ChainServiceRegister

func ChainServiceRegister(r ...ServiceRegister) ServiceRegister

type ServiceRegisterFunc

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

func (ServiceRegisterFunc) Register

func (f ServiceRegisterFunc) 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