Documentation ¶
Index ¶
- Constants
- func ListenAndServe(gate *Gateway, handler http.Handler) error
- func RegisterHandler(gate *Gateway) func(key string, handlerFunc handler.Func)
- func RemoveService(gate *Gateway) ...
- func Shutdown(gate *Gateway) error
- func UseMiddleware(gate *Gateway) func(key string, mwf middleware.Func)
- type AddRouteFunc
- type AddServiceFunc
- type Config
- type EndpointConfig
- type Gateway
- type UpdateEndpointFunc
Constants ¶
const DefaultHandlerType = handler.ReverseProxyHandlerType
DefaultHandlerType is the default handler used when a request matches a route
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
ListenAndServe start the gateway server
func RegisterHandler ¶
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 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
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