Documentation
¶
Index ¶
- Constants
- 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 Body
- type CorsConfig
- type DebugHandlerConfig
- type GRPCStatus
- type GrpcAccessLog
- type GrpcAccessLogParam
- type GrpcConfig
- type Http3Config
- type Metadata
- type OpenapiConfig
- type Option
- func WithContext(ctx context.Context) Option
- func WithCors(handler func(cors *cors.Options)) 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 WithHttpHandler(handler http.Handler) Option
- func WithInternalServer(handler func(s *http.Server)) 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 ¶
View Source
const ( ContentTypeJson = "json" ContentTypeProtobuf = "protobuf" )
View Source
const ScopeName = "github.com/hopeio/mix"
Variables ¶
View Source
var MetadataKey = metadataKey{}
Functions ¶
func DefaultAccessLog ¶
func DefaultAccessLog(ctx context.Context, param *AccessLogParam)
func DefaultGrpcAccessLog ¶
func DefaultGrpcAccessLog(ctx context.Context, param *GrpcAccessLogParam)
Types ¶
type AccessLog ¶
type AccessLog = func(ctx context.Context, pram *AccessLogParam)
type AccessLogConfig ¶
type AccessLogParam ¶
type CorsConfig ¶
type DebugHandlerConfig ¶
type GRPCStatus ¶
type GrpcAccessLog ¶
type GrpcAccessLog = func(ctx context.Context, pram *GrpcAccessLogParam)
type GrpcAccessLogParam ¶
type GrpcConfig ¶
type GrpcConfig struct {
Addr string
RecordFunc GrpcAccessLog
Options []grpc.ServerOption
UnaryServerInterceptors []grpc.UnaryServerInterceptor
StreamServerInterceptors []grpc.StreamServerInterceptor
}
type Http3Config ¶
type Metadata ¶
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
RequestAt time.Time
GrpcMD metadata.MD // grpc only
ServerTransportStream grpc.ServerTransportStream // grpc only
AccessLogFields []zap.Field
Bagage baggage.Baggage // can not edit
}
func GetMetadata ¶
type OpenapiConfig ¶
type Option ¶
type Option func(server *Server)
func WithContext ¶
func WithGrpc ¶
func WithGrpc(handler func(option *GrpcConfig)) Option
func WithGrpcHandler ¶
func WithHTTP3 ¶
func WithHTTP3(handler func(s *Http3Config)) Option
func WithHttpHandler ¶
func WithInternalServer ¶
func WithMiddleware ¶
func WithMiddleware(mw ...httpx.Middleware) Option
func WithOtel ¶
func WithOtel(handler func(otel *OtelConfig)) Option
type OtelConfig ¶
type OtelConfig struct {
Enabled bool
OtelhttpOpts []otelhttp.Option
OtelgrpcOpts []otelgrpc.Option
}
func (*OtelConfig) SetOtelgrpcOptions ¶
func (c *OtelConfig) SetOtelgrpcOptions(otelgrpcOpts []otelgrpc.Option)
func (*OtelConfig) SetOtelhttpOptions ¶
func (c *OtelConfig) SetOtelhttpOptions(otelhttpOpts []otelhttp.Option)
type PrometheusConfig ¶
type PrometheusConfig struct {
Enabled bool
HttpURI string
promhttp.HandlerOpts
}
type RequestType ¶
type RequestType int
const ( RequestTypeHttp RequestType = iota RequestTypeGrpc )
type Server ¶
type Server struct {
http.Server
CertFile string
KeyFile string
AccessLog AccessLogConfig
HTTP3 Http3Config
Cors CorsConfig
Grpc GrpcConfig
InternalServer http.Server
Openapi OpenapiConfig
Otel OtelConfig
DebugHandler DebugHandlerConfig
BaseContext context.Context
Middlewares []httpx.Middleware
HttpHandler http.Handler
GrpcHandler func(*grpc.Server)
// contains filtered or unexported fields
}
func (*Server) AfterInject ¶
func (s *Server) AfterInject()
func (*Server) InternalHandler ¶
func (s *Server) InternalHandler()
func (*Server) StreamAccess ¶
func (s *Server) StreamAccess(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error)
func (*Server) UnaryAccess ¶
func (s *Server) UnaryAccess(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)
func (*Server) WithOptions ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.
