Documentation ¶
Index ¶
- func ErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, ...)
- func IncomingHeaderMatcher(key string) (string, bool)
- func OutgoingHeaderMatcher(key string) (string, bool)
- func RegisterServices(services []*Service, opts *RegisterServicesOptions) (http.Handler, error)
- func WithAuthentication(except []string) func(http.Handler) http.Handler
- func WithAuthenticationDetails(handler http.Handler, authenticate AuthenticationHandler) http.Handler
- func WithCORSEnabled(options *CORSOptions) func(http.Handler) http.Handler
- func WithHydraAuthenticationDetails(handler http.Handler) http.Handler
- func WithRequestLogger(l *log.Entry) func(http.Handler) http.Handler
- type AuthenticationHandler
- type AuthenticationResult
- type CORSOptions
- type LoggingResponseWriter
- type RegisterServicesOptions
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorHandler ¶
func IncomingHeaderMatcher ¶
IncomingHeaderMatcher is the default incoming header matcher for the gateway.
It matches all Foundation headers and uses the default matcher for all other headers.
func OutgoingHeaderMatcher ¶
OutgoingHeaderMatcher is the default outgoing header matcher for the gateway.
It matches all Foundation headers and uses the default matcher for all other headers.
func RegisterServices ¶
func RegisterServices(services []*Service, opts *RegisterServicesOptions) (http.Handler, error)
func WithAuthentication ¶
WithAuthentication is a middleware that forces the request to be authenticated
func WithAuthenticationDetails ¶
func WithAuthenticationDetails(handler http.Handler, authenticate AuthenticationHandler) http.Handler
WithAuthenticationDetails is a middleware that fetches the authentication details using the given authentication function
func WithCORSEnabled ¶
func WithCORSEnabled(options *CORSOptions) func(http.Handler) http.Handler
WithCORSEnabled is a middleware that enables CORS for the given handler.
func WithHydraAuthenticationDetails ¶
WithHydraAuthenticationDetails is a middleware that fetches the authentication details using ORY Hydra
Types ¶
type AuthenticationHandler ¶
type AuthenticationHandler func(token string) (*AuthenticationResult, error)
AuthenticationHandler is a function that authenticates the request
type AuthenticationResult ¶
type AuthenticationResult struct { // IsAuthenticated is true if the request is authenticated IsAuthenticated bool // ClientID is the OAuth2 client ID of the authenticated user (if any) ClientID string // UserID is the user ID of the authenticated user UserID string // Scope is the OAuth2 scope of the authenticated user Scope string // Metadata is the additional metadata for the authenticated user Metadata map[string]string }
AuthenticationResult is the result of an authentication
type CORSOptions ¶
type CORSOptions struct { // AllowedOrigin is the allowed origin for CORS. AllowedOrigin string // MaxAge is the max age for CORS. MaxAge *time.Duration // AllowedHeaders are the allowed headers for CORS. AllowedHeaders []string // ExposedHeaders are the exposed headers for CORS. ExposedHeaders []string // AllowedMethods are the allowed methods for CORS. AllowedMethods []string }
CORSOptions represents the options for CORS.
func NewCORSOptions ¶
func NewCORSOptions() *CORSOptions
type LoggingResponseWriter ¶
type LoggingResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
LoggingResponseWriter is an http.ResponseWriter that tracks the status code of the response.
func NewLoggingResponseWriter ¶
func NewLoggingResponseWriter(w http.ResponseWriter) *LoggingResponseWriter
NewLoggingResponseWriter creates a new loggingResponseWriter that wraps the provided http.ResponseWriter. If WriteHeader is not called, the response will implicitly return a status code of 200 OK.
func (*LoggingResponseWriter) WriteHeader ¶
func (lrw *LoggingResponseWriter) WriteHeader(code int)
WriteHeader sets the status code of the response and calls the underlying ResponseWriter's WriteHeader method.
type RegisterServicesOptions ¶
type RegisterServicesOptions struct { // Mux options MuxOpts []runtime.ServeMuxOption // TLS directory TLSDir string }
type Service ¶
type Service struct { // Name of the service, used for environment variable lookup in the form of `GRPC_<NAME>_ENDPOINT` Name string // Function to register the gRPC server endpoint Register func(context.Context, *runtime.ServeMux, string, []grpc.DialOption) error }
Service represents a gRPC service that can be registered with the gateway.