http

package
v0.0.0-...-f382dc8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRequesrID

func AddRequesrID(handler http.Handler) http.Handler

AddRequesrID 给每个请求加上 request id

func Cors

func Cors(next http.Handler) http.Handler

Cors 跨域支持

func WithLogger

func WithLogger(handler http.Handler) http.Handler

WithLogger 记录 http 请求日志 Middleware

Types

type GatewayOptions

type GatewayOptions struct {
	// 存放生成的 Swager json 文件的目录
	SwaggerJSONDir string
	// Swagger UI 前段文件目录
	SwaggerUIDir string
	// Grpc server address
	GrpcServerAddr string
}

func (GatewayOptions) IsValid

func (v GatewayOptions) IsValid() error

type GatewayServer

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

GatewayServer is the gateway server for the grpc server.

func NewGatewayServer

func NewGatewayServer(opts *GatewayOptions) (*GatewayServer, error)

NewGatewayServer creates a new GatewayServer.

func (*GatewayServer) Serve

func (gw *GatewayServer) Serve(ctx context.Context, address string) error

Serve forever. The argument address is the address to bind this http server.

type MiddlewareChain

type MiddlewareChain struct {
	MiddlewareInterceptors []MiddlewareInterceptor
}

MiddlewareChain is a collection of interceptors that will be invoked in there index order

func NewMiddlewareChain

func NewMiddlewareChain(ms ...MiddlewareInterceptor) MiddlewareChain

NewMiddlewareChain 创建一个新的 middlewareChain

func (MiddlewareChain) Handler

Handler allows hooking multiple MiddlewareInterceptor in single call.

func (MiddlewareChain) Intercept

func (p MiddlewareChain) Intercept(h http.Handler) http.Handler

Intercept returns back a continuation that will call install MiddlewareInterceptor to intercept the continuation call.

type MiddlewareInterceptor

type MiddlewareInterceptor func(http.Handler) http.Handler

MiddlewareInterceptor intercepts an HTTP handler invocation, it is passed both response writer and request which after interception can be passed onto the handler function.

Jump to

Keyboard shortcuts

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