Versions in this module Expand all Collapse all v1 v1.21.4 Aug 5, 2026 v1.21.3 Aug 5, 2026 Changes in this version + var CommonTag = "json" + var DefaultMarshal MarshalFunc = func(ctx context.Context, v any) (data []byte, contentType string, err error) + var DefaultMemory int64 = 32 << 20 + var DefaultUnmarshal UnmarshalFunc = func(ctx context.Context, contentType string, data []byte, v any) error + var ErrHeaderKey errHeaderKey + var Validate = validator.ValidateStruct + func Bind(r *http.Request, v any) error + func CommonBind(s Source, v any) error + func HandlerWrapCommon[REQ, RESP any](service types.Service[*REQ, *RESP]) http.Handler + func HandlerWrap[REQ, RESP any](service Service[*REQ, *RESP]) http.Handler + func JsonMarshal(ctx context.Context, v any) ([]byte, string, error) + func RegisterErrCode(code ErrCode, msg string) + func RegisterErrCodeHttpStatus(code ErrCode, status int) + func RegisterErrCodeMap(enum map[int32]string) + func RespodWithErrHeader(ctx context.Context) context.Context + func Respond(ctx context.Context, w http.ResponseWriter, data any) (int, error) + func RespondErrCodeMsg(ctx context.Context, w http.ResponseWriter, code ErrCode, msg string) + func RespondError(ctx context.Context, w http.ResponseWriter, err error) (int, error) + func RespondSSE[T ~string](ctx context.Context, w http.ResponseWriter, dataSource iter.Seq[T]) (int, error) + func RespondStream(ctx context.Context, w http.ResponseWriter, ...) (int, error) + func RespondSuccess(ctx context.Context, w http.ResponseWriter, res any) (int, error) + func Serve(w http.ResponseWriter, r *http.Request, data any) + func ServeErrCodeMsg(w http.ResponseWriter, r *http.Request, code ErrCode, msg string) + func ServeError(w http.ResponseWriter, r *http.Request, err error) + func ServeSuccess(w http.ResponseWriter, r *http.Request, res any) + func SetMultipartFrormFile(value reflect.Value, field *reflect.StructField, files []*multipart.FileHeader) (isSet bool, err error) + func StatusFromErrCode(code ErrCode) int + func UnWrapContext(ctx context.Context) any + func WrapContext(v any) context.Context + type BidiStream interface + Recv func() (ReqPtr, error) + Send func(RespPtr) error + type BidiStreamHandler func(S) error + type BindFunc func(r Source, v any) error + type Binder interface + Bind func(r *http.Request, v any) error + type ClientSideStream interface + Recv func() (ReqPtr, error) + SendAndClose func(RespPtr) error + type ClientSideStreamHandler func(S) error + type Codec interface + type CommonAnyResp = CommonResp[any] + func NewCommonAnyResp(code ErrCode, msg string, data any) *CommonAnyResp + type CommonBinder interface + Bind func(r Source, v any) error + type CommonProtoResp CommonResp[T] + func NewCommonProtoResp[T proto.Message](code ErrCode, msg string, data T) *CommonProtoResp[T] + func (r *CommonProtoResp[T]) MarshalProto() ([]byte, error) + func (r *CommonProtoResp[T]) UnmarshalProto(data []byte) error + type CommonResp struct + Code ErrCode + Data T + Msg string + func (res *CommonResp[T]) Respond(ctx context.Context, w http.ResponseWriter) (int, error) + func (res *CommonResp[T]) ServeHTTP(w http.ResponseWriter, r *http.Request) + type Delimited interface + Delimiter func() []byte + type ErrCode int32 + const Aborted + const AlreadyExists + const Canceled + const DataLoss + const DeadlineExceeded + const FailedPrecondition + const Internal + const InvalidArgument + const NotFound + const OutOfRange + const PermissionDenied + const ResourceExhausted + const Success + const Unauthenticated + const Unavailable + const Unimplemented + const Unknown + func (x ErrCode) ErrResp() *ErrResp + func (x ErrCode) Error() string + func (x ErrCode) GRPCStatus() *status.Status + func (x ErrCode) Msg(msg string) *ErrResp + func (x ErrCode) String() string + func (x ErrCode) Wrap(err error) *ErrResp + type ErrResp struct + Code ErrCode + Msg string + func ErrRespFrom(err error) *ErrResp + func NewErrResp(code ErrCode, msg string) *ErrResp + func (res *ErrResp) ErrResp() *ErrResp + func (res *ErrResp) Respond(ctx context.Context, w http.ResponseWriter) (int, error) + func (res *ErrResp) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (x *ErrResp) Error() string + func (x *ErrResp) GRPCStatus() *status.Status + func (x *ErrResp) MarshalJSON() ([]byte, error) + type Field struct + Field *reflect.StructField + Index int + Name string + Tags []Tag + type GrpcHandler func(ctx context.Context, in ReqPtr) (RespPtr, error) + type HeaderSource map[string][]string + func (hs HeaderSource) Get(key string) ([]string, bool) + type MarshalFunc func(ctx context.Context, v any) (data []byte, contentType string, err error) + type Marshaler interface + Marshal func(ctx context.Context, v any) (data []byte, contentType string) type Metadata + Baggage baggage.Baggage + IncomingMD metadata.MD + func (m *Metadata) GetData() any + func (m *Metadata) SetData(value any) + type MultipartSource multipart.Form + func (ms *MultipartSource) TrySet(value reflect.Value, field *reflect.StructField, key string, ...) (isSet bool, err error) + type ProtoMessage interface + type QuerySource map[string][]string + func (req QuerySource) Get(key string) ([]string, bool) + type ReqResp struct + type RequestSource struct + func (s RequestSource) Body() (context.Context, string, io.ReadCloser) + func (s RequestSource) Header() kvstruct.ValuesGetter + func (s RequestSource) Query() kvstruct.ValuesGetter + func (s RequestSource) Uri() kvstruct.Getter + type Responder interface + Respond func(ctx context.Context, w http.ResponseWriter) (int, error) + type Response struct + Body iox.WriterToCloser + Headers http.Header + Status int + func (res *Response) Respond(ctx context.Context, w http.ResponseWriter) (int, error) + func (res *Response) ServeHTTP(w http.ResponseWriter, r *http.Request) + type ResponseBody interface + ResponseBody func() ([]byte, string) + type ResponseFile struct + Body iox.WriterToCloser + ContentType string + Name string + func (res *ResponseFile) Respond(ctx context.Context, w http.ResponseWriter) (int, error) + func (res *ResponseFile) ServeHTTP(w http.ResponseWriter, r *http.Request) + type ResponseStream struct + Body iter.Seq[iox.WriterToCloser] + Headers http.Header + Status int + func (res *ResponseStream) Respond(ctx context.Context, w http.ResponseWriter) (int, error) + func (res *ResponseStream) ServeHTTP(w http.ResponseWriter, r *http.Request) + type ResponseWriter interface + HeaderX func() httpx.Header + Write func([]byte) (int, error) + WriteHeader func(code int) + type SSEData string + func (data SSEData) Close() error + func (data SSEData) WriteTo(w io.Writer) (int64, error) + type ServerSideStream interface + Send func(RespPtr) error + type ServerSideStreamHandler func(ReqPtr, S) error + type Service func(ctx ReqResp, req REQ) (RESP, *ErrResp) + type Source interface + Body func() (context.Context, string, io.ReadCloser) + Header func() kvstruct.ValuesGetter + Query func() kvstruct.ValuesGetter + Uri func() kvstruct.Getter + type StatusCode interface + StatusCode func(v any) int + type StreamContentType interface + StreamContentType func(v any) string + type Tag struct + Key string + Options *kvstruct.Options + Value string + type UnmarshalFunc func(ctx context.Context, contentType string, data []byte, v any) error + type Unmarshaler interface + Unmarshal func(ctx context.Context, contentType string, data []byte, v any) error + type UriSource http.Request + func (req *UriSource) Get(key string) (string, bool) + type XXXResponseBody interface + XXX_ResponseBody func() any v1.21.2 Jul 7, 2026 Changes in this version + const ContentTypeJson + const ContentTypeProtobuf + const ScopeName + var MetadataKey = metadataKey + 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 = func(ctx context.Context, pram *AccessLogParam) + type AccessLogConfig struct + ExcludePrefixes []string + IncludePrefixes []string + RecordFunc AccessLog + type AccessLogParam struct + Metadata *Metadata + Method string + Url string + type Body struct + ContentType string + Data any + Raw []byte + type CorsConfig struct + Enabled bool + type DebugHandlerConfig struct + Enabled bool + UriPrefix string + type GRPCStatus interface + GRPCStatus func() *status.Status + type GrpcAccessLog = func(ctx context.Context, pram *GrpcAccessLogParam) + type GrpcAccessLogParam struct + Err error + Metadata *Metadata + Method string + Request any + Response any + type GrpcConfig struct + Addr string + Options []grpc.ServerOption + RecordFunc GrpcAccessLog + StreamServerInterceptors []grpc.StreamServerInterceptor + UnaryServerInterceptors []grpc.UnaryServerInterceptor + type Http3Config struct + CertFile string + Enabled bool + KeyFile string + type Metadata struct + AccessLogFields []zap.Field + AuthID string + AuthRaw []byte + Bagage baggage.Baggage + Data any + DataM map[any]any + GrpcMD metadata.MD + Logger *log.Logger + Request *http.Request + RequestAt time.Time + RequestType RequestType + ResponseWriter http.ResponseWriter + ServerTransportStream grpc.ServerTransportStream + Token string + TraceId string + func GetMetadata(ctx context.Context) *Metadata + func (m *Metadata) Del(key any) + func (m *Metadata) Get(key any) any + func (m *Metadata) Set(key, value any) + type OpenapiConfig struct + Dir string + Enabled bool + UriPrefix string + type Option func(server *Server) + 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 struct + Enabled bool + OtelgrpcOpts []otelgrpc.Option + OtelhttpOpts []otelhttp.Option + func (c *OtelConfig) SetOtelgrpcOptions(otelgrpcOpts []otelgrpc.Option) + func (c *OtelConfig) SetOtelhttpOptions(otelhttpOpts []otelhttp.Option) + type PrometheusConfig struct + Enabled bool + HttpURI string + type RequestType int + const RequestTypeGrpc + const RequestTypeHttp + type Server struct + AccessLog AccessLogConfig + BaseContext context.Context + CertFile string + Cors CorsConfig + DebugHandler DebugHandlerConfig + Grpc GrpcConfig + GrpcHandler func(*grpc.Server) + HTTP3 Http3Config + HttpHandler http.Handler + InternalServer http.Server + KeyFile string + Middlewares []httpx.Middleware + Openapi OpenapiConfig + Otel OtelConfig + func NewServer(options ...Option) *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