Documentation ¶
Index ¶
- Constants
- Variables
- func CreateJSONBodyMarshaler() *runtime.HTTPBodyMarshaler
- func DefaultAPI[REQ, RES any](ctx context.Context, req *REQ, serviceFunc ServiceFunc[REQ, RES], ...) (*RES, error)
- func DefaultEP[REQ, RES any](ctx context.Context, serviceFunc ServiceFunc[REQ, RES]) endpoint.Endpoint
- func DefaultEPCall[RES any](ctx context.Context, ep endpoint.Endpoint, req interface{}) (*RES, error)
- func GetReqIdFromCtx(ctx context.Context) string
- func ValidateReq(req interface{}) error
- func WithLoggingEPMiddleware() endpoint.Middleware
- func WithReqValidatorEPMiddleware() endpoint.Middleware
- type CtxKey
- type Server
- type ServerOptions
- type ServiceFunc
Constants ¶
View Source
const ( MdKeyGRPCMethod = "grpc_method" MdKeyHTTPMethod = "http_method" MdKeyHTTPHost = "http_host" MdKeyHTTPPath = "http_path" MdKeyHTTPRemote = "http_remote" MdKeyHTTPRequestID = "request_id" HTTPHdrRequestID = "X-Request-Id" )
Variables ¶
View Source
var ( ErrReqInvalidType = status.Error(codes.Internal, "invalid request type") ErrReqInvalid = status.Error(codes.InvalidArgument, "request validation failed") )
Errors
Functions ¶
func CreateJSONBodyMarshaler ¶
func CreateJSONBodyMarshaler() *runtime.HTTPBodyMarshaler
func DefaultAPI ¶
func DefaultAPI[REQ, RES any](ctx context.Context, req *REQ, serviceFunc ServiceFunc[REQ, RES], middlewareOptions ...endpoint.Middleware) (*RES, error)
DefaultAPI is a convenience function for handling API requests.
func DefaultEP ¶
func DefaultEP[REQ, RES any](ctx context.Context, serviceFunc ServiceFunc[REQ, RES]) endpoint.Endpoint
DefaultEP returns an endpoint that calls the service function.
func DefaultEPCall ¶
func DefaultEPCall[RES any](ctx context.Context, ep endpoint.Endpoint, req interface{}) (*RES, error)
DefaultEPCall validates the request and calls the given handler.
func GetReqIdFromCtx ¶
func ValidateReq ¶
func ValidateReq(req interface{}) error
ValidateReq runs validation on the proto request object.
func WithLoggingEPMiddleware ¶
func WithLoggingEPMiddleware() endpoint.Middleware
WithLoggingEPMiddleware returns a middleware that logs API calls.
func WithReqValidatorEPMiddleware ¶
func WithReqValidatorEPMiddleware() endpoint.Middleware
WithReqValidatorEPMiddleware returns a middleware that validates the request.
Types ¶
type Server ¶
type Server struct { HTTPMux *runtime.ServeMux HTTPMw []func(http.Handler) http.Handler GRPCServer *grpc.Server Options ServerOptions }
Server represents the server object.
func NewServer ¶
func NewServer(options ServerOptions) *Server
NewServer creates a new instance of the Server.
type ServerOptions ¶
ServerOptions holds the server configuration options.
Click to show internal directories.
Click to hide internal directories.