Documentation ¶
Index ¶
- type Option
- type Server
- func (s *Server) RegisterService(desc *grpc.ServiceDesc, impl interface{})
- func (s *Server) Serve(listener net.Listener) error
- func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)
- func (s *Server) SetServingStatus(service string, status healthgrpc.HealthCheckResponse_ServingStatus)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
func GRPCWebDisabled ¶ added in v0.0.4
func GRPCWebDisabled() Option
GRPCWebDisabled disables the grpc-web endpoint.
func InsecureHealth ¶ added in v0.0.4
func InsecureHealth() Option
InsecureHealth disables authentication on the health endpoint. Otherwise, the health endpoint will be protected by the authentication middleware and requires at least a valid token or certificate.
func WithEmbeddedMetricsEndpoint ¶
func WithEmbeddedMetricsEndpoint() Option
WithEmbeddedMetricsEndpoint enables the prometheus metrics on the /metrics endpoint. Please note that when using a custom http handler this option will not be applied successfully.
func WithGinMiddleware ¶ added in v0.0.4
func WithGinMiddleware(middleware gin.HandlerFunc) Option
WithGinMiddleware adds a gin middleware to the server. This is necessary to achieve the correct ordering of middlewares as the ordering has a direct impact on the functionality of the middlewares.
func WithReadTimeout ¶
WithReadTimeout sets the read timeout for the http server.
type Server ¶
type Server struct { *gin.Engine TLSConfig *tls.Config GrpcWebDisabled bool GrpcWeb *grpcweb.WrappedGrpcServer Grpc *grpc.Server HTTPHandler http.Handler Server *http.Server Healthcheck *health.Server ReadTimeout time.Duration InsecureHealth bool Authorizer auth.Authorizer }
Server is an opinionated server implementation multiplexing grpc, grpc-web and rest/http on a single port. It embeds gin.Engine and the grpc.ServiceRegistrar interface to directly interact with the server.
func (*Server) RegisterService ¶
func (s *Server) RegisterService(desc *grpc.ServiceDesc, impl interface{})
RegisterService implements the grpc.ServiceRegistrar interface used to register services with the grpc server. ServiceRegistrar wraps a single method that supports service registration. It enables users to pass concrete types other than grpc.Server to the service registration methods exported by the IDL generated code.
func (*Server) Serve ¶
Serve starts the server on the given listener. It will automatically detect if the server is configured to use TLS.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)
ServeHTTP implements the http.Handler interface used internally to route requests to the correct handler. This function handles the selection of the correct handler (grpc, grpc-web or http) based on the content-type header.
func (*Server) SetServingStatus ¶
func (s *Server) SetServingStatus(service string, status healthgrpc.HealthCheckResponse_ServingStatus)
SetServingStatus is called when need to reset the serving status of a service or insert a new service entry into the statusMap.