Documentation ¶
Index ¶
- type AuthenticationMiddleware
- type Option
- func DisableGrpcWeb() Option
- func WithEmbeddedMetricsEndpoint() Option
- func WithInsecureHealth() Option
- func WithJwtKeyFunc(keyFunc jwt.Keyfunc) Option
- func WithJwtToken(token jwt.Claims) Option
- func WithMTLSConfig(pool *x509.CertPool, server *tls.Certificate) Option
- func WithReadTimeout(timeout time.Duration) 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 AuthenticationMiddleware ¶
type AuthenticationMiddleware struct {
// contains filtered or unexported fields
}
func NewAuthenticationMiddleware ¶
func NewAuthenticationMiddleware(jwtKeyFunc jwt.Keyfunc, jwtToken jwt.Claims) *AuthenticationMiddleware
func (*AuthenticationMiddleware) Middleware ¶
func (*AuthenticationMiddleware) StreamServerInterceptor ¶
func (middleware *AuthenticationMiddleware) StreamServerInterceptor() grpc.StreamServerInterceptor
func (*AuthenticationMiddleware) UnaryServerInterceptor ¶
func (middleware *AuthenticationMiddleware) UnaryServerInterceptor() grpc.UnaryServerInterceptor
type Option ¶
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 WithInsecureHealth ¶
func WithInsecureHealth() Option
WithInsecureHealth 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 WithJwtKeyFunc ¶
func WithJwtKeyFunc(keyFunc jwt.Keyfunc) Option
WithJwtKeyFunc sets the jwt key function for the authentication middleware.
func WithJwtToken ¶
func WithJwtToken(token jwt.Claims) Option
WithJwtToken sets the jwt token for the authentication middleware.
func WithMTLSConfig ¶
func WithMTLSConfig(pool *x509.CertPool, server *tls.Certificate) Option
WithMTLSConfig sets the mTLS configuration for the server. This requires client certificates signed by a ca from the pool and will serve with the given Certificate.
func WithReadTimeout ¶
WithReadTimeout sets the read timeout for the http server.
type Server ¶
Server is an opinionated implementation of server providing grpc, grpc-web and rest/http endpoints on a single port.
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.