Documentation ¶
Index ¶
- Constants
- Variables
- func CreateGateway(ctx context.Context, conn *grpc.ClientConn, ...) (*gwRuntime.ServeMux, error)
- func CreateGatewayEndpoint(ctx context.Context, endpoint string, ...) (*gwRuntime.ServeMux, error)
- func NewParalusJSON() runtime.Marshaler
- func Run(ctx context.Context, opts ...GatewayOption) error
- type AnnotatorFunc
- type Gateway
- type GatewayOption
- func WithAddress(addr string) GatewayOption
- func WithAnnotator(annotator ...AnnotatorFunc) GatewayOption
- func WithConn(conn *grpc.ClientConn) GatewayOption
- func WithEndpoint(endpoint *url.URL) GatewayOption
- func WithHandlers(handlers ...HandlerFunc) GatewayOption
- func WithListener(lis net.Listener) GatewayOption
- func WithNetwork(network string) GatewayOption
- func WithServeMuxOptions(serveMuxOptions ...gwRuntime.ServeMuxOption) GatewayOption
- func WithShutdownFunc(f func()) GatewayOption
- func WithTLSConfig(c *tls.Config) GatewayOption
- func WithTimeout(timeout time.Duration) GatewayOption
- type HandlerFromEndpoint
- type HandlerFunc
Constants ¶
const ( GatewayRequest = "x-gateway-request" GatewayURL = "x-gateway-url" GatewaySessionCookie = "ory_kratos_session" GatewayAPIKey = "X-Session-Token" APIKey = "X-API-KEYID" APIKeyToken = "X-API-TOKEN" GatewayMethod = "x-gateway-method" UserAgent = "x-gateway-user-agent" Host = "x-gateway-host" RemoteAddr = "x-gateway-remote-addr" )
Paralus Gateway annotations
Variables ¶
var ParalusGatewayAnnotator = func(ctx context.Context, r *http.Request) metadata.MD { return metadata.New(map[string]string{ GatewayRequest: "true", GatewayURL: r.URL.EscapedPath(), GatewayAPIKey: r.Header.Get(GatewayAPIKey), APIKey: r.Header.Get(APIKey), APIKeyToken: r.Header.Get(APIKeyToken), GatewayMethod: r.Method, UserAgent: r.UserAgent(), Host: r.Host, RemoteAddr: r.RemoteAddr, }) }
ParalusGatewayAnnotator adds paralus gateway specific annotations
Functions ¶
func CreateGateway ¶
func CreateGateway( ctx context.Context, conn *grpc.ClientConn, serveMuxOptions []gwRuntime.ServeMuxOption, annotators []AnnotatorFunc, handlers ...HandlerFunc, ) (*gwRuntime.ServeMux, error)
CreateGateway returns new grpc gateway
func CreateGatewayEndpoint ¶
func CreateGatewayEndpoint( ctx context.Context, endpoint string, serveMuxOptions []gwRuntime.ServeMuxOption, dialOptions []grpc.DialOption, annotators []AnnotatorFunc, handlers ...HandlerFromEndpoint, ) (*gwRuntime.ServeMux, error)
CreateGatewayEndpoint returns new grpc gateway
func NewParalusJSON ¶
NewParalusJSON returns new grpc gateway paralus json marshaller
Types ¶
type AnnotatorFunc ¶
AnnotatorFunc is the annotator function is for injecting metadata from http request into gRPC context
type Gateway ¶
type Gateway struct { *http.Server // if you need gRPC gw,please use it // contains filtered or unexported fields }
func ApplyGateway ¶
func ApplyGateway(opts ...GatewayOption) *Gateway
func NewGateway ¶
func NewGateway(ctx context.Context, opts ...GatewayOption) *Gateway
type GatewayOption ¶
type GatewayOption func(o *Gateway)
GatewayOption is gRPC Gateway option.
func WithAddress ¶
func WithAddress(addr string) GatewayOption
func WithAnnotator ¶
func WithAnnotator(annotator ...AnnotatorFunc) GatewayOption
WithAnnotator returns an Option to append some annotator
func WithConn ¶
func WithConn(conn *grpc.ClientConn) GatewayOption
func WithEndpoint ¶
func WithEndpoint(endpoint *url.URL) GatewayOption
func WithHandlers ¶
func WithHandlers(handlers ...HandlerFunc) GatewayOption
func WithListener ¶
func WithListener(lis net.Listener) GatewayOption
func WithNetwork ¶
func WithNetwork(network string) GatewayOption
func WithServeMuxOptions ¶
func WithServeMuxOptions(serveMuxOptions ...gwRuntime.ServeMuxOption) GatewayOption
func WithShutdownFunc ¶
func WithShutdownFunc(f func()) GatewayOption
WithShutdownFunc returns an Option to register a function which will be called when server shutdown
func WithTLSConfig ¶
func WithTLSConfig(c *tls.Config) GatewayOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) GatewayOption
type HandlerFromEndpoint ¶
type HandlerFromEndpoint func(ctx context.Context, mux *gwRuntime.ServeMux, endpoint string, opts []grpc.DialOption) error
HandlerFromEndpoint is the callback that the caller should implement to steps to reverse-proxy the HTTP/1 requests to gRPC handlerFromEndpoint http gw endPoint automatically dials to "endpoint" and closes the connection when "ctx" gets done.