Documentation
¶
Index ¶
- Variables
- func DefaultAccessLog(ctx context.Context, param *AccessLogParam)
- func DefaultGrpcAccessLog(ctx context.Context, param *GrpcAccessLogParam)
- func WithMetadata(ctx context.Context, metadata *Metadata) context.Context
- type AccessLog
- type AccessLogConfig
- type AccessLogParam
- type ApiDocConfig
- type Body
- type CorsConfig
- type DebugHandlerConfig
- type GRPCStatus
- type GrpcAccessLog
- type GrpcAccessLogParam
- type GrpcConfig
- type Http2Config
- type Http3Config
- type Metadata
- type Option
- func WithContext(ctx context.Context) Option
- func WithCors(handler func(cors *cors.Options)) Option
- func WithGinHandler(handler func(*gin.Engine)) Option
- func WithGrpc(handler func(option *GrpcConfig)) Option
- func WithGrpcHandler(handler func(*grpc.Server)) Option
- func WithHTTP3(handler func(s *Http3Config)) Option
- func WithHttp(handler func(s *http.Server)) Option
- func WithHttp2(handler func(s *Http2Config)) Option
- func WithMiddleware(mw ...httpx.Middleware) Option
- func WithOtel(handler func(otel *OtelConfig)) Option
- type OtelConfig
- type PrometheusConfig
- type RequestType
- type Server
- func (s *Server) AfterInject()
- func (s *Server) BeforeInject()
- func (s *Server) Init()
- func (s *Server) InternalHandler()
- func (s *Server) Run()
- func (s *Server) StreamAccess(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, ...) (err error)
- func (s *Server) UnaryAccess(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (resp interface{}, err error)
- func (s *Server) WithContext(ctx context.Context) *Server
- func (s *Server) WithOptions(options ...Option) *Server
Constants ¶
This section is empty.
Variables ¶
View Source
var MetadataKey = metadataKey{}
Functions ¶
func DefaultAccessLog ¶ added in v1.17.20
func DefaultAccessLog(ctx context.Context, param *AccessLogParam)
func DefaultGrpcAccessLog ¶ added in v1.19.12
func DefaultGrpcAccessLog(ctx context.Context, param *GrpcAccessLogParam)
Types ¶
type AccessLog ¶
type AccessLog = func(ctx context.Context, pram *AccessLogParam)
type AccessLogConfig ¶ added in v1.19.11
type AccessLogParam ¶ added in v1.17.15
type ApiDocConfig ¶ added in v1.18.6
type CorsConfig ¶ added in v1.18.6
type DebugHandlerConfig ¶ added in v1.18.16
type GRPCStatus ¶ added in v1.19.13
type GrpcAccessLog ¶ added in v1.19.12
type GrpcAccessLog = func(ctx context.Context, pram *GrpcAccessLogParam)
type GrpcAccessLogParam ¶ added in v1.19.12
type GrpcConfig ¶ added in v1.18.6
type GrpcConfig struct {
RecordFunc GrpcAccessLog
EnableGrpcWeb bool
GrpcWebOptions []web.Option
Options []grpc.ServerOption
UnaryServerInterceptors []grpc.UnaryServerInterceptor
StreamServerInterceptors []grpc.StreamServerInterceptor
}
type Http2Config ¶ added in v1.20.28
type Http2Config struct {
NewWriteScheduler func() http2.WriteScheduler
}
type Http3Config ¶ added in v1.20.28
type Metadata ¶ added in v1.20.26
type Metadata struct {
sync.RWMutex
Logger *log.Logger
Data any
DataM map[any]any
TraceId string
RequestType RequestType
Token string
AuthRaw []byte
AuthID string
Request *http.Request
ResponseWriter http.ResponseWriter
GinContext *gin.Context // http only
RequestAt time.Time
GrpcMD metadata.MD // grpc only
ServerTransportStream grpc.ServerTransportStream // grpc only
AccessLogFields []zap.Field
Bagage baggage.Baggage // can not edit
}
func GetMetadata ¶ added in v1.20.26
type Option ¶ added in v1.16.7
type Option func(server *Server)
func WithContext ¶ added in v1.16.7
func WithGinHandler ¶ added in v1.16.7
func WithGrpc ¶ added in v1.18.6
func WithGrpc(handler func(option *GrpcConfig)) Option
func WithGrpcHandler ¶ added in v1.16.7
func WithHTTP3 ¶ added in v1.18.6
func WithHTTP3(handler func(s *Http3Config)) Option
func WithHttp2 ¶ added in v1.19.11
func WithHttp2(handler func(s *Http2Config)) Option
func WithMiddleware ¶ added in v1.19.12
func WithMiddleware(mw ...httpx.Middleware) Option
func WithOtel ¶ added in v1.20.27
func WithOtel(handler func(otel *OtelConfig)) Option
type OtelConfig ¶ added in v1.20.26
type OtelConfig struct {
Enabled bool
OtelhttpOpts []otelhttp.Option
OtelgrpcOpts []otelgrpc.Option
}
func (*OtelConfig) SetOtelgrpcOptsHandlerOpts ¶ added in v1.20.26
func (c *OtelConfig) SetOtelgrpcOptsHandlerOpts(otelgrpcOpts []otelgrpc.Option)
func (*OtelConfig) SetOtelhttpHandlerOpts ¶ added in v1.20.26
func (c *OtelConfig) SetOtelhttpHandlerOpts(otelhttpOpts []otelhttp.Option)
type PrometheusConfig ¶ added in v1.19.11
type PrometheusConfig struct {
Enabled bool
HttpURI string
promhttp.HandlerOpts
}
type RequestType ¶ added in v1.20.26
type RequestType int
const ( RequestTypeHttp RequestType = iota RequestTypeGrpc RequestTypeGrpcWeb )
type Server ¶
type Server struct {
http.Server
CertFile string
KeyFile string
AccessLog AccessLogConfig
HTTP2 Http2Config
HTTP3 Http3Config
Cors CorsConfig
Grpc GrpcConfig
InternalServer http.Server
ApiDoc ApiDocConfig
Otel OtelConfig
Prometheus PrometheusConfig
DebugHandler DebugHandlerConfig
BaseContext context.Context
Middlewares []httpx.Middleware
GinServer *gin.Engine
GrpcHandler func(*grpc.Server)
}
func (*Server) AfterInject ¶ added in v1.16.17
func (s *Server) AfterInject()
func (*Server) BeforeInject ¶ added in v1.16.17
func (s *Server) BeforeInject()
implement initialize
func (*Server) InternalHandler ¶ added in v1.18.16
func (s *Server) InternalHandler()
func (*Server) StreamAccess ¶ added in v1.19.20
func (s *Server) StreamAccess(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error)
func (*Server) UnaryAccess ¶ added in v1.16.7
func (s *Server) UnaryAccess(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)
func (*Server) WithContext ¶ added in v1.20.26
func (*Server) WithOptions ¶ added in v1.16.7
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
_example
|
|
|
client
command
|
|
|
protobuf/user
Package user is a reverse proxy.
|
Package user is a reverse proxy. |
|
user
command
|
|
Click to show internal directories.
Click to hide internal directories.
