Documentation ¶
Index ¶
- Variables
- func DefaultBindOverrideToFlags() (flags []string)
- func EnvOverrideDefaultBind() bool
- func GetDefaultSiteURL(ctx context.Context, sites ...*install.ProxyConfig) string
- func GetPublicBaseDavSegment(ctx context.Context) string
- func GetPublicBaseUri(ctx context.Context) string
- func GetSitesAllowedURLs(ctx context.Context) map[string]*url.URL
- func LoadSites(ctx context.Context, configOnly ...bool) ([]*install.ProxyConfig, error)
- func RegisterRoute(id, description, defaultURI string, opts ...RouteOption)
- func ResolvedURIFromContext(ctx context.Context) string
- func SaveSites(ctx context.Context, sites []*install.ProxyConfig, user, msg string) error
- func SiteContextDiscoveryRoutes(ctx context.Context, uriForSameSite ...bool) (map[string][]*url.URL, error)
- func SiteFromContext(ctx context.Context, ss []*install.ProxyConfig) (*install.ProxyConfig, *url.URL, bool)
- func StripPrefixKeepSlash(prefix string, h http.Handler) http.Handler
- func ToXDS(site *install.ProxyConfig, upstreamsResolver UpstreamsResolver) (*route.VirtualHost, error)
- type ActiveProxy
- type ActiveRoute
- type HandleOption
- type HandleOptions
- type RequestRewriter
- type Rewriter
- type RewritesResolver
- type Route
- type RouteOption
- type RouteOptions
- type RouteRegistrar
- type TLSResolver
- type UpstreamsResolver
Constants ¶
This section is empty.
Variables ¶
var ( DefaultBindingSite = &install.ProxyConfig{ Binds: []string{"0.0.0.0:" + runtime.DefaultBindingSitePort}, TLSConfig: &install.ProxyConfig_SelfSigned{SelfSigned: &install.TLSSelfSigned{}}, SSLRedirect: false, } ConfigPath = []string{"defaults", "sites"} ConfigPathFormated = configx.FormatPath("defaults", "sites") )
Functions ¶
func DefaultBindOverrideToFlags ¶
func DefaultBindOverrideToFlags() (flags []string)
func EnvOverrideDefaultBind ¶
func EnvOverrideDefaultBind() bool
func GetDefaultSiteURL ¶
func GetDefaultSiteURL(ctx context.Context, sites ...*install.ProxyConfig) string
GetDefaultSiteURL returns the first available bindURL of all available sites
func GetPublicBaseDavSegment ¶
GetPublicBaseDavSegment returns the segment used to exposed minisites through DAV
func GetPublicBaseUri ¶
GetPublicBaseUri returns the default public uri
func GetSitesAllowedURLs ¶
GetSitesAllowedURLs returns a map of hostname => url for all sites. TODO : this function could switch to a list of specific authorized hostnames
func LoadSites ¶
LoadSites returns all sites defined by order of preference : - ENV VARS - YAML CONFIG - INTERNAL CONFIG - If none is found, returns a default value If configOnly is set to true, will only return the ones saved in configs
func RegisterRoute ¶
func RegisterRoute(id, description, defaultURI string, opts ...RouteOption)
RegisterRoute registers a generic route by a unique ID, which URI will be resolved at runtime
func ResolvedURIFromContext ¶
ResolvedURIFromContext reads resolved URI from context
func SiteFromContext ¶
func SiteFromContext(ctx context.Context, ss []*install.ProxyConfig) (*install.ProxyConfig, *url.URL, bool)
SiteFromContext lookups for siteHash in the context
func StripPrefixKeepSlash ¶
StripPrefixKeepSlash returns a handler that serves HTTP requests by removing the given prefix from the request URL's Path (and RawPath if set) and invoking the handler h. StripPrefixKeepSlash handles a request for a path that doesn't begin with prefix by replying with an HTTP 404 not found error. The prefix must match exactly: if the prefix in the request contains escaped characters the reply is also an HTTP 404 not found error.
It differs from http.StripPrefix by keeping a "/" if resulting path is ""
func ToXDS ¶
func ToXDS(site *install.ProxyConfig, upstreamsResolver UpstreamsResolver) (*route.VirtualHost, error)
ToXDS is a WIP implementation for generating XDS configuration from active proxy
Types ¶
type ActiveProxy ¶
type ActiveProxy struct { *install.ProxyConfig Routes []*ActiveRoute // Resolved values TLS string TLSCert string TLSKey string }
func ResolveProxy ¶
func ResolveProxy(proxyConfig *install.ProxyConfig, tlsResolver TLSResolver, rewriteResolver RewritesResolver, upstreamResolver UpstreamsResolver) (*ActiveProxy, error)
ResolveProxy is used with custom resolvers to resolve a proxyConfig to a runtime-usable configuration. Resolvers are implemented by proxies to write correct configuration files
func (*ActiveProxy) Redirects ¶
func (s *ActiveProxy) Redirects() map[string]string
Redirects compute required redirects if SSLRedirect is set
type ActiveRoute ¶
type HandleOption ¶
type HandleOption func(o *HandleOptions)
HandleOption provides functional access for HandleOptions
func WithEnsureTrailing ¶
func WithEnsureTrailing() HandleOption
WithEnsureTrailing will double registration to pattern and pattern+"/" to make sure
func WithRewriteCatchAll ¶
func WithRewriteCatchAll() HandleOption
WithRewriteCatchAll points this handler as catch-all - If request was not handled before, it can be rewritten to this handler resolved pattern and applied
func WithStripPrefix ¶
func WithStripPrefix() HandleOption
WithStripPrefix will wrap the handler **at runtime** with a http.StripPrefix middleware and the resolved URI
type HandleOptions ¶
HandleOptions can be used to pass options to the Handle method
type RequestRewriter ¶
type Rewriter ¶
type Rewriter func(req *http.Request, currentRegistrar RouteRegistrar)
type RewritesResolver ¶
type RewritesResolver func(active *ActiveRoute, route Route, rule *install.Rule)
RewritesResolver converts generic rewrite instructions into runtime-usable directives
type Route ¶
type Route interface { GetID() string GetDescription() string GetURI() string SupportSubPath() bool Endpoint(pattern string) string // Handle registers a handler Handle(pattern string, handler http.Handler, opts ...HandleOption) // Deregister a specific pattern from the current route Deregister(pattern string) }
Route can be seen as a Router for a given route ID
type RouteOption ¶
type RouteOption func(o *RouteOptions)
RouteOption is the functional access to RouteOptions
func WithCustomResolver ¶
func WithCustomResolver(r func(ctx context.Context) string) RouteOption
WithCustomResolver sets a dynamic resolver to compute default URI value
func WithoutSubPathSupport ¶
func WithoutSubPathSupport() RouteOption
WithoutSubPathSupport declares this route as not being able to be served on a sub-folder URI
type RouteOptions ¶
type RouteOptions struct { DefaultURI string CustomResolver func(ctx context.Context) string NoSubPath bool }
RouteOptions are used to pass options to the route declaration
type RouteRegistrar ¶
type RouteRegistrar interface { Route(id string) Route DeregisterRoute(id string) RegisterRewrite(id string, rewriter Rewriter) DeregisterRewrite(id string) Patterns(routeIDs ...string) []string ApplyRewrites(req *http.Request) CanRewriteAndCatchAll(req *http.Request) (b bool) IteratePatterns(func(pattern string, handler http.Handler)) }
RouteRegistrar is used to declare routes and their patterns
func NewRouteRegistrar ¶
func NewRouteRegistrar() RouteRegistrar
NewRouteRegistrar creates a RouteRegistrar interface implementation
type TLSResolver ¶
type TLSResolver func(site *ActiveProxy) error
TLSResolver converts TLS config into runtime-usable tls directives