noopgateway

package
v1.41.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler struct {
	// Service is the service containing the auth handler.
	Service ServiceName
	Name    string // name of the auth handler

	// Parameters that the auth handler expects.
	// If any one of these are present in the request,
	// the auth handler is invoked.
	Query  []Param
	Header []Param
	Cookie []Param
}

AuthHandler describes the auth handler.

type Description

type Description struct {
	// Routes are the routes to proxy.
	Routes []*Route

	// Services defines how to proxy traffic to each service.
	Services map[ServiceName]Service

	// Auth describes the authentication handler, if any.
	Auth *AuthHandler
}

Description describes a gateway.

type Gateway

type Gateway struct {
	// Rewrite allows for rewriting the request before it is proxied.
	// If nil it does nothing.
	Rewrite func(p *httputil.ProxyRequest)

	// RoundTripper is the http.RoundTripper to use. It defaults to http.DefaultTransport.
	RoundTripper http.RoundTripper

	// ExtraRoutes, if non-nil, specifies a router that will be consulted first.
	// Requests will be proxied to the backend only if the router has no matching path.
	ExtraRoutes *mux.Router
	// contains filtered or unexported fields
}

Gateway implements a gateway that validates and authenticates incoming requests, and forwards them to the appropriate service.

func New

func New(desc *Description) *Gateway

New constructs a new gateway.

func (*Gateway) ServeHTTP

func (g *Gateway) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

type Param

type Param struct {
	// WireFormat is the name of the parameter on the wire.
	WireFormat string
	// CaseSensitive specifies whether or not
	// the wire format is case sensitive.
	CaseSensitive bool
}

Param describes a request parameter.

type RetryDialer

type RetryDialer struct {
	net.Dialer
	MaxBackoff time.Duration
}

RetryDialer wraps another dialer and adds exponential backoff in the case of connection refused errors.

func (*RetryDialer) DialContext

func (d *RetryDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

type Route

type Route struct {
	Methods []string    // HTTP methods
	Path    string      // "/path/:param/*wildcard"
	Dest    ServiceName // where to route the request

	// RequiresAuth specifies whether the route requires authentication.
	RequiresAuth bool
}

Route defines a single route in the gateway.

type Service

type Service struct {
	// URL is the URL to proxy traffic to.
	URL *url.URL
}

Service describes how to route traffic to a service.

type ServiceName

type ServiceName string

ServiceName is the name of a service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL