gateway

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultHandlerType = handler.ReverseProxyHandlerType

DefaultHandlerType is the default handler used when a request matches a route

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(gate *Gateway, handler http.Handler) error

ListenAndServe start the gateway server

func RegisterHandler

func RegisterHandler(gate *Gateway) func(key string, handlerFunc handler.Func)

RegisterHandler registers a new handler

func RemoveService

func RemoveService(gate *Gateway) func(removeRouteFunc func(routeId string)) func(service servicediscovery.Service)

RemoveService removes a service from the gateway

func Shutdown

func Shutdown(gate *Gateway) error

func UseMiddleware

func UseMiddleware(gate *Gateway) func(key string, mwf middleware.Func)

UseMiddleware registers a new middleware

Types

type AddRouteFunc

type AddRouteFunc func(path string, pathPrefix string, methods []string, handler http.Handler) (string, error)

AddRouteFunc is a type for adding routes using the same signature

type AddServiceFunc

type AddServiceFunc func(addRouteFunc AddRouteFunc) func(service servicediscovery.Service)

AddServiceFunc is a type for adding services using the same signature

func AddService

func AddService(gate *Gateway) AddServiceFunc

AddService adds a service to the gateway

type Config

type Config struct {
	Endpoints                    []EndpointConfig `mapstructure:"endpoints"`
	Port                         int              `mapstructure:"port"`
	Version                      string           `mapstructure:"version"`
	Name                         string           `mapstructure:"name"`
	UpstreamPathPrefix           string           `mapstructure:"upstream_path_prefix"`
	DownstreamPathPrefix         string           `mapstructure:"downstream_path_prefix"`
	LogLevel                     string           `mapstructure:"log_level"`
	InCluster                    bool             `mapstructure:"in_cluster"`
	OverrideServiceAddress       string           `mapstructure:"override_service_address"`
	ServiceNamespacePrefixFilter string           `mapstructure:"service_namespace_prefix_filter"`
}

Config is an object loaded from config.json

type EndpointConfig

type EndpointConfig struct {
	UpstreamPath         string                 `mapstructure:"upstream_path"`
	UpstreamPathPrefix   string                 `mapstructure:"upstream_path_prefix"`
	DownstreamPath       string                 `mapstructure:"downstream_path"`
	DownstreamPathPrefix string                 `mapstructure:"downstream_path_prefix"`
	ServiceName          string                 `mapstructure:"service_name"`
	Methods              []string               `mapstructure:"methods"`
	HandlerType          string                 `mapstructure:"handler_type"`
	HandlerConfig        map[string]interface{} `mapstructure:"handler_config"`
	Filters              map[string]interface{} `mapstructure:"filters"`
}

EndpointConfig is a configuration detail from config.json

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

Gateway is a http.Handler able to route request to different handlers

func NewGateway

func NewGateway(config *Config, loggerFactory log.Factory) *Gateway

NewGateway is the Gateway constructor

type UpdateEndpointFunc

type UpdateEndpointFunc func(addRouteFunc AddRouteFunc, removeRouteFunc func(routeId string)) func(oldService servicediscovery.Service, newService servicediscovery.Service)

UpdateEndpointFunc is a type for updating endpoints using the same signature

func UpdateService

func UpdateService(gate *Gateway) UpdateEndpointFunc

UpdateService updates a service of the gateway

Jump to

Keyboard shortcuts

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