jar

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 85 Imported by: 0

README

jar

Package jar is a readily-embeddable feature-rich proxy-focused AWS-aware distributed-oriented resiliency-enabling URL-driven superlative-laced elastic application link. At its core, JAR is "just" a load-balancing proxy taking cues from HAProxy (resiliency, zero-drop restarts, performance) and Apache HTTPD (virtualize everything) while leveraging over 20 years of systems engineering experience to provide robust features with exceptional stability.

JAR has been in production use since 2018 and handles millions of connections a day across heterogeneous application stacks.

Consumers will want to 'cd cmd/jard; go build; #enjoy'

Documentation

Overview

Package jar is a readily-embeddable feature-rich proxy-focused AWS-aware distributed-oriented resiliency-enabling URL-driven superlative-laced ***elastic application link***. At its core, JAR is "just" a load-balancing proxy taking cues from HAProxy (resiliency, zero-drop restarts, performance) and Apache HTTPD (virtualize everything) while leveraging over 20 years of systems engineering experience to provide robust features with exceptional stability.

JAR has been in production use since 2018 and handles millions of connections a day across heterogeneous application stacks.

Consumers will want to 'cd cmd/jard; go build; #enjoy'

Index

Constants

View Source
const (
	// ErrBootstrapDone should not be treated as a proper error, as it is returned if Bootstrap
	// is complete (e.g. checkconfig or doc output), and won't continue for non-error reasons
	ErrBootstrapDone = Error("Bootstrap() is done. This is not necessarily an error")

	// ErrPoolBuild is a panic in bootstrap() if BuildPools fails
	ErrPoolBuild = Error("error building pools")

	// ErrValidateExtras is a panic in bootstrap() if there are any errors in ValidateExtras.
	// Preceding error output may provide more specific information.
	ErrValidateExtras = Error("error validating extras")

	// ErrVersion is a panic in bootstrap() if versionrequired is set in the config, but is less
	// than the VERSION constant of the compiled binary reading the config.
	ErrVersion = Error("version requirement not met")
)
View Source
const (
	// ErrSourceVerificationFailed is an error returned when an authentication source cannot be verified
	ErrSourceVerificationFailed = Error("cannot verify the provided source")

	// ErrSourceNotSupported is an error returned when the authentication source scheme is not supported [yet]
	ErrSourceNotSupported = Error("specified source scheme is not supported")
)
View Source
const (
	// ConfigGroupCachePeers is a config for a list of peers, ala “http://127.0.0.1:8080,http://127.0.0.1:8081,http://127.0.0.1:8082
	ConfigGroupCachePeers = ConfigKey("groupcache.peerlist")
	// ConfigGroupCacheAddr is a config key for my listening address, ala “:8080“
	ConfigGroupCacheAddr = ConfigKey("groupcache.listenaddress")

	// ConfigCacheSizeMB is the size- in megabytes- the cache should be. Defaults to 16.
	ConfigCacheSizeMB = ConfigKey("cache.sizemb")
	// ConfigCacheMaxItemSizeB is the size - in bytes - at which an item will not be cached.
	ConfigCacheMaxItemSizeB = ConfigKey("cache.maxitemsize")
	// ConfigCacheExpiration is the duration in which an item should live in the cache. Default is "until evicted".
	ConfigCacheExpiration = ConfigKey("cache.expiration")
	// ConfigCacheControlHeader is the value to append to a `Cache-Control` response header. Default is to omit the header.
	ConfigCacheControlHeader = ConfigKey("cache.controlheader")

	// NoCacheDefinedError is returned when a Path has CacheName set, but no cache has been globally configured.
	NoCacheDefinedError = Error("path requests a cache, but no cache defined")
	// CacheAlreadyDefinedError is returned when a Path has CacheName set, but that CacheName has already been used.
	CacheAlreadyDefinedError = Error("path requests a new cache that already exists")
)
View Source
const (
	ConfigAccessLog            = ConfigKey("accesslog")
	ConfigAuthPool             = ConfigKey("authpool")
	ConfigCheckConfig          = ConfigKey("checkconfig")
	ConfigCommonLog            = ConfigKey("commonlog")
	ConfigDebug                = ConfigKey("debug")
	ConfigDebugLog             = ConfigKey("debuglog")
	ConfigDebugRequests        = ConfigKey("debugrequests")
	ConfigDebugResponses       = ConfigKey("debugresponses")
	ConfigDebugTimings         = ConfigKey("debugtimings")
	ConfigDumpConfig           = ConfigKey("dumpconfig")
	ConfigEC2                  = ConfigKey("ec2")
	ConfigErrorLog             = ConfigKey("errorlog")
	ConfigHandlers             = ConfigKey("handlers")
	ConfigHotConfig            = ConfigKey("hotconfig")
	ConfigHotUpdate            = ConfigKey("hotupdate")
	ConfigKeepaliveTimeout     = ConfigKey("keepalivetimeout")
	ConfigKeys                 = ConfigKey("keys")
	ConfigKeysAwsRegion        = ConfigKey("keys.aws.region")
	ConfigKeysAwsAccessKey     = ConfigKey("keys.aws.access")
	ConfigKeysAwsSecretKey     = ConfigKey("keys.aws.secret")
	ConfigListen               = ConfigKey("listen")
	ConfigLogAge               = ConfigKey("logage")
	ConfigLogBackups           = ConfigKey("logbackups")
	ConfigLogSize              = ConfigKey("logsize")
	ConfigMaxConnections       = ConfigKey("maxconnections")
	ConfigPaths                = ConfigKey("paths")
	ConfigPools                = ConfigKey("pools")
	ConfigRequestIDHeaderName  = ConfigKey("requestidheadername")
	ConfigSlowLog              = ConfigKey("slowlog")
	ConfigSlowRequestMax       = ConfigKey("slowrequestmax")
	ConfigStripRequestHeaders  = ConfigKey("striprequestheaders")
	ConfigTempFolder           = ConfigKey("tempfolder")
	ConfigTimeout              = ConfigKey("timeout")
	ConfigTrustRequestIDHeader = ConfigKey("trustrequestidheader")
	ConfigUpdatePath           = ConfigKey("updatepath")
	ConfigAuthoritativeDomains = ConfigKey("authoritativedomains")
	ConfigVersionRequired      = ConfigKey("versionrequired")
	ConfigLogFakeXFF           = ConfigKey("fakexfflog")

	ConfigURLRouteHeaders            = ConfigKey("urlroute.enableheaders")
	ConfigURLRouteIDHeaderName       = ConfigKey("urlroute.idheadername")
	ConfigURLRouteEndpointHeaderName = ConfigKey("urlroute.endpointheadername")
	ConfigURLRouteNameHeaderName     = ConfigKey("urlroute.nameheadername")
	ConfigPoolHeaderName             = ConfigKey("urlroute.poolheadername")
	ConfigPoolMemberHeaderName       = ConfigKey("urlroute.poolmemberheadername")
)

Constants for configuration key strings

View Source
const (
	ConfigCORSAllowCredentials = ConfigKey("CORS.allowcredentials")
	ConfigCORSAllowHeaders     = ConfigKey("CORS.allowheaders")
	ConfigCORSAllowMethods     = ConfigKey("CORS.allowmethods")
	ConfigCORSOrigins          = ConfigKey("CORS.origins")
	ConfigCORSMaxAge           = ConfigKey("CORS.maxage")
	ConfigCORSPrivateNetwork   = ConfigKey("CORS.privatenetwork")

	CORSAllowOrigin      = CorsString("Access-Control-Allow-Origin")
	CORSAllowCredentials = CorsString("Access-Control-Allow-Credentials")
	CORSExposeHeaders    = CorsString("Access-Control-Expose-Headers")
	CORSAllowMethods     = CorsString("Access-Control-Allow-Methods")
	CORSAllowHeaders     = CorsString("Access-Control-Allow-Headers")
	CORSMaxAge           = CorsString("Access-Control-Max-Age")
	CORSPrivateNetwork   = CorsString("Access-Control-Request-Private-Network")
)

Constants for configuration key strings

View Source
const (
	// ErrCiphertextTooShort is returned when the ciphertext is too damn short
	ErrCiphertextTooShort = Error("ciphertext too short")

	// ErrCiphertextIrregular is returned when the ciphertext is not a multiple of the block size
	ErrCiphertextIrregular = Error("ciphertext is not a multiple of the block size")
)
View Source
const (
	ConfigTLSCerts             = ConfigKey("tls.certs")
	ConfigTLSCiphers           = ConfigKey("tls.ciphers")
	ConfigTLSEnabled           = ConfigKey("tls.enabled")
	ConfigTLSHTTPRedirects     = ConfigKey("tls.httpredirects")
	ConfigTLSKeepaliveDisabled = ConfigKey("tls.keepalivedisabled")
	ConfigTLSListen            = ConfigKey("tls.listen")
	ConfigTLSMaxVersion        = ConfigKey("tls.maxversion")
	ConfigTLSMinVersion        = ConfigKey("tls.minversion")
	ConfigTLSHTTP2             = ConfigKey("tls.http2")
)

Constants for configuration key strings

View Source
const (

	// ErrPreviousError is exclusive to the HandleSuddenEviction scheme,
	// and announces that original error should be the one returned to the caller
	ErrPreviousError = Error("previous error stands")

	// ErrAuthError is used to communicate authentication errors. More detail
	// will be in the error log, but let's not leak that, shall we?
	ErrAuthError = Error("an error occurred during AAA")

	// ErrForbiddenError is used to communicate resource access denial
	ErrForbiddenError = Error("you do not have access to this resource")

	// ErrNoSession is called when an AWS feature is called, but there is no initialized AWS session
	ErrNoSession = Error("there is no initialized AWS session")

	// ErrUnknownError is returned when an error occurs for undefined-yet-anticipated reasons
	ErrUnknownError = Error("unknown error")
)
View Source
const (
	ConfigErrorHandlerTemplate = ConfigKey("errorhandler.template")
	ConfigErrorHandlerURI      = ConfigKey("errorhandler.uri")
)

Constants for configuration key strings

View Source
const (
	StatusClientClosedRequest     = 499
	StatusClientClosedRequestText = "Client Closed Request"
)

Constants for miscellaneous conditions

View Source
const (

	// PathOptionsKey is a keyid for setting/getting PathOptions to/from a Context
	PathOptionsKey commonIDKey

	// ErrAborted is only used during panic recovery, if http.ErrAbortHandler was called
	ErrAborted = Error("client aborted connection, or connection closed")
)
View Source
const (
	ConfigHeaders                 = ConfigKey("headers")
	ConfigRecovererLogStackTraces = ConfigKey("Recoverer.logstacktraces")
)

Constants for configuration key strings

View Source
const (
	// ErrNoSuchEntryError is returned by the Status Registry when no status exists for the requested thing
	ErrNoSuchEntryError = Error("no such element exists")

	// ErrNoSuchHealthCheckStatus is returned when a string-based status has been used, but no corresponding HealthCheckStatus exists
	ErrNoSuchHealthCheckStatus = Error("no such HealthCheckStatus exists")
)
View Source
const (
	ConfigHMACKey            = ConfigKey("hmac.key")
	ConfigHMACSalt           = ConfigKey("hmac.salt")
	ConfigHMACExpiration     = ConfigKey("hmac.expiration")
	ConfigHMACExpirationName = ConfigKey("hmac.expirationfield")
)

PathOptions for HMAC signing

View Source
const (
	ConfigCompression     = ConfigKey("compression")
	ConfigDisableRealAddr = ConfigKey("disablerealaddr")
	ConfigForbiddenPaths  = ConfigKey("forbiddenpaths")
)

Constants for configuration key strings

View Source
const (
	// ErrPoolsConfigdefaultmembererrorstatusInvalid is returned when the pools.defaultmembererrorstatus is set improperly
	ErrPoolsConfigdefaultmembererrorstatusInvalid = Error("pools.defaultmembererrorstatus is set to an invalid HealthCheckStatus")

	// ErrPoolsConfigdefaultmembererrorstatusEmpty is returned when the pools.defaultmembererrorstatus is empty
	ErrPoolsConfigdefaultmembererrorstatusEmpty = Error("pools.defaultmembererrorstatus is empty")

	// ErrPoolStickyAESNoKey is returned when materializing a Pool with StickyCookieType set to 'aes' but 'keys.stickycookie' is not set
	ErrPoolStickyAESNoKey = Error("Pool.StickyCookieType set to 'aes' but no keys.stickycookie set")

	// ErrPoolAddMemberNotSupported is returned when Pool.AddMember is called on a Pool that doesn't support the operation
	ErrPoolAddMemberNotSupported = Error("this Pool does not support dynamic adding of members")

	// ErrPoolDeleteMemberNotSupported is returned when Pool.DeleteMember is called on a Pool that doesn't support the operation
	ErrPoolDeleteMemberNotSupported = Error("this Pool does not support dynamic deletion of members")

	// ErrPoolRemoveMemberNotSupported is returned when Pool.RemoveMember is called on a Pool that doesn't support the operation
	ErrPoolRemoveMemberNotSupported = Error("this Pool does not support dynamic removing of members")

	// ErrPoolNoMembersConfigured is returned when a non-dynamic Pool type (e.g. S3) has no members configured
	ErrPoolNoMembersConfigured = Error("no members configured for a non-dynamic Pool")

	// ErrPoolConfigConsistentAndSticky is returned when a Pool has both Sticky and ConsistentHashing set
	ErrPoolConfigConsistentAndSticky = Error("a Pool cannot have Sticky and ConsistentHashing set")

	// ErrPoolConfigMissing is returned when an operation on a Pool is requested, but no config is set
	ErrPoolConfigMissing = Error("no Config present for Pool")
)
View Source
const (
	ConfigKeysStickyCookie           = ConfigKey("keys.stickycookie")
	ConfigStickyCookieAESTTL         = ConfigKey("stickycookie.aes.ttl")
	ConfigStickyCookieHTTPOnly       = ConfigKey("stickycookie.httponly")
	ConfigStickyCookieSecure         = ConfigKey("stickycookie.secure")
	ConfigConsistentHashPartitions   = ConfigKey("consistenthash.partitions")
	ConfigConsistentHashReplications = ConfigKey("consistenthash.replfactor")
	ConfigConsistentHashLoad         = ConfigKey("consistenthash.load")
)

Constants for configuration key strings

View Source
const (
	// ErrConsistentHashNextServerUnsupported is returned if NextServer is called
	ErrConsistentHashNextServerUnsupported = Error("Consistent Hash Pools don't support NextServer")

	// ErrConsistentHashInvalidSource is returned the source is not one of "request", "header", or "cookie"
	ErrConsistentHashInvalidSource = Error("the consistent hash source provided is not valid")

	// ErrConsistentHashSourceNameImbalance is returned when the configured lists are not of the same lengths
	ErrConsistentHashSourceNameImbalance = Error("ConsistentHashSources and ConsistentHashNames are not balanced lists")
)
View Source
const (
	// ErrNoSuchMemberError is returned if the member doesn't exist or has been removed from a Pool
	ErrNoSuchMemberError = Error("member no longer exists in pool")
	// NoPoolsError is returned if there are no pools, but a Build was requested
	NoPoolsError = Error("there are no pools to build")
)
View Source
const (
	ConfigPoolsDefaultMemberErrorStatus               = ConfigKey("pools.defaultmembererrorstatus")
	ConfigPoolsDefaultMemberWeight                    = ConfigKey("pools.defaultmemberweight")
	ConfigPoolsHealthcheckInterval                    = ConfigKey("pools.healthcheckinterval")
	ConfigPoolsLocalMemberWeight                      = ConfigKey("pools.localmemberweight")
	ConfigPoolsPreMaterialize                         = ConfigKey("pools.prematerialize")
	ConfigPoolsDefaultConsistentHashPartitions        = ConfigKey("pools.defaultconsistenthashpartitions")
	ConfigPoolsDefaultConsistentHashReplicationFactor = ConfigKey("pools.defaultconsistenthashreplicationfactor")
	ConfigPoolsDefaultConsistentHashLoad              = ConfigKey("pools.defaultconsistenthashload")
)

Constants for configuration key strings

View Source
const (
	ConfigS3StreamProxyName              = ConfigKey("s3proxy.name")
	ConfigS3StreamProxyBucket            = ConfigKey("s3proxy.bucket")
	ConfigS3StreamProxyPrefix            = ConfigKey("s3proxy.prefix")
	ConfigS3StreamProxyRedirectURL       = ConfigKey("s3proxy.redirecturl")
	ConfigS3StreamProxyFormNameField     = ConfigKey("s3proxy.namefield")
	ConfigS3StreamProxyFormEmailField    = ConfigKey("s3proxy.emailfield")
	ConfigS3StreamProxyFormToField       = ConfigKey("s3proxy.tofield")
	ConfigS3StreamProxyFormFileField     = ConfigKey("s3proxy.filefield")
	ConfigS3StreamProxyBadFileExtensions = ConfigKey("s3proxy.badfileexts")
	ConfigS3StreamProxyWrapSuccess       = ConfigKey("s3proxy.wrapsuccess")
	ConfigS3StreamProxyZulipStream       = ConfigKey("s3proxy.zulipstream")
	ConfigS3StreamProxyZulipTopic        = ConfigKey("s3proxy.zuliptopic")
)

Constants for configuration key strings

View Source
const (
	ConfigTUSTargetURI      = ConfigKey("tus.targeturi")
	ConfigTUSAppendFilename = ConfigKey("tus.appendfilename")
	ErrTUSTargetURIMissing  = Error("tus.targeturi missing from path options")
)

Constants for configuration key strings and Errors

View Source
const (
	// ErrUpdateConfigS3NoAWS is returned when the s3 updatepath is set, but AWS is not.
	ErrUpdateConfigS3NoAWS = Error("s3 updatepath set, but AWS is not configured")

	// ErrUpdateConfigEmptyURL is returned when the updatepath is empty
	ErrUpdateConfigEmptyURL = Error("update url is empty, not updating")
)
View Source
const (
	ConfigMapFiles                 = ConfigKey("mapfiles")
	ConfigMapIDMap                 = ConfigKey("urlroute.idmap")
	ConfigMapEndpointMap           = ConfigKey("urlroute.endpointmap")
	ConfigSwitchHandlerEnforce     = ConfigKey("SwitchHandler.enforce")
	ConfigSwitchHandlerStripPrefix = ConfigKey("SwitchHandler.stripprefix") // e.g. xzy strips ^xyz.*-
)

Constants for configuration key strings

View Source
const (
	ConfigZulipBaseURL       = ConfigKey("zulip.url")
	ConfigZulipUsername      = ConfigKey("zulip.username")
	ConfigZulipToken         = ConfigKey("zulip.token")
	ConfigZulipRetryCount    = ConfigKey("zulip.retrycount")
	ConfigZulipRetryInterval = ConfigKey("zulip.retryinterval")
)

Constants for configuration key strings

View Source
const (
	ConfigWorkersInitialPoolSize = ConfigKey("workers.initialpoolsize")
	ConfigWorkersMaxPoolSize     = ConfigKey("workers.maxpoolsize")
	ConfigWorkersMinPoolSize     = ConfigKey("workers.minpoolsize")
	ConfigWorkersQueueSize       = ConfigKey("workers.queuesize")
	ConfigWorkersResizeInterval  = ConfigKey("workers.resizeinterval")
)

Constants for configuration key strings

View Source
const (
	ConfigMacros = ConfigKey("macros")
)

Constants for configuration key strings

View Source
const (
	// ErrFinisher404 returned by HandleFinisher if the requested finisher doesn't exist. Other errors should be treated as failures
	ErrFinisher404 = Error("requested finisher does not exist")
)
View Source
const (
	// ErrInvalidS3URL is returned when the relevant URL parts from the provided S3 URL cannot be derived
	ErrInvalidS3URL = Error("the S3 URL passed is invalid")
)
View Source
const (
	// ErrNoZulipClient is returned by a worker when there is no Zulip client defined
	ErrNoZulipClient = Error("no Zulip client defined")
)
View Source
const (
	// ErrS3ProxyConfigNoAWS is returned when the s3proxy is used, but AWS is not.
	ErrS3ProxyConfigNoAWS = Error("s3proxy used, but AWS is not configured")
)

Variables

View Source
var (
	// Conf is the config struct
	Conf *viper.Viper

	// StopFuncs is an aggregator for functions that needs to be called during graceful shutdowns.
	// Can only be called once!
	StopFuncs = funcregistry.NewFuncRegistry(true)

	// StrainFuncs is an aggregator for functions that can be called when JAR is under resource pressure.
	StrainFuncs = funcregistry.NewFuncRegistry(false)

	// InitFuncs are called in the early phases of Bootstrap()
	InitFuncs = funcregistry.NewFuncRegistry(true)

	// FileWatcher is an abstracted mechanism for calling WatchHandlerFuncs when a file is changed
	FileWatcher *watcher.Watcher

	// LoadBalancers are Pools
	LoadBalancers *Pools

	// Seq is a Sequence used for request ids
	Seq = sequence.New(1)

	// AWSSession is an aws.Session for use in various places
	AWSSession *aws.Session

	// Caches is a GroupCache used for various subsystems
	Caches *CacheCluster

	// Hostname is a local cache of os.Hostname
	Hostname string
)
View Source
var (
	// ConfigValidations is used to wire in func()error to be run, validating distributed configs
	ConfigValidations = make(map[string]func() error)
	// ConfigAdditions is used to wire in additional default configurations
	ConfigAdditions = make(configDefaultSetter)
)
View Source
var (
	// Finishers is a map of available HandlerFuncs
	Finishers = make(FinisherMap)

	// FinisherSetups is a map of Finishers that need exec-time setup checks
	FinisherSetups = make(map[string]FinisherSetupFunc)
)
View Source
var (
	// Metrics is a Registry for metrics, to be reported in the healthcheck
	Metrics = metrics.NewRegistry()
	// Status is a Registry for statuses, to be reported in the healthcheck
	Status = health.NewStatusRegistry()

	// NUMCPU is the number of CPUs at starttime
	NUMCPU = runtime.NumCPU()
	// GOVERSION is the version of Go
	GOVERSION = runtime.Version()

	// Counter is the clicker to a request counter.
	Counter func()

	// ThisProcess is updated information about this process
	ThisProcess *ProcessInfo

	// ConnectionCounter is used for tracking the current number of connections served
	ConnectionCounter int64

	// CurrentHealthCheck is a cache of the current state, refreshed periodically
	CurrentHealthCheck atomic.Value

	// HealthCheck is a Finisher that writes the healthcheck
	HealthCheck = healthCheckAsync

	// TerseHealthCheck is a Finisher that writes the terse healthcheck
	TerseHealthCheck = terseHealthCheckAsync
)
View Source
var (

	// CheckAuthoritative compares domain suffixes in the "authoritativedomains" against the requested URL.Hostname()
	// and returns true if it matches or if "authoritativedomains" is not used
	CheckAuthoritative = func(*http.Request) bool { return true }

	// RecyclableBufferPool is a pool of recyclable.Buffers that are safe to Get() and use (after a reset), and then
	// Close() them when you're done, to put them back in the Pool
	RecyclableBufferPool = recyclable.NewBufferPool()
)
View Source
var (
	// OutFormat is a log.Logger format used by default
	OutFormat = log.Ldate | log.Ltime | log.Lshortfile
	// DebugOut is a log.Logger for debug messages
	DebugOut = log.New(io.Discard, "[DEBUG] ", 0)
	// TimingOut is a log.Logger for timing-related debug messages. DEPRECATED
	TimingOut = log.New(io.Discard, "[TIMING] ", 0)
	// ErrorOut is a log.Logger for error messages
	ErrorOut = log.New(os.Stderr, "", OutFormat)
	// AccessOut is a log.Logger for access logging. PLEASE DO NOT USE THIS DIRECTLY
	AccessOut = log.New(os.Stdout, "", 0)
	// CommonOut is a log.Logger for Apache "common log format" logging. PLEASE DO NOT USE THIS DIRECTLY
	CommonOut = log.New(io.Discard, "", 0)
	// SlowOut is a log.Logger for slow request information
	SlowOut = log.New(io.Discard, "", 0)

	// RequestTimer is a function to allow Durations to be added to the Timer Metric
	RequestTimer func(time.Duration)

	// SlowRequests is the slow request log Duration
	SlowRequests time.Duration

	// LogPool is a Pool of AccessLogs
	LogPool sync.Pool
)
View Source
var (
	// DefaultTrip should be used instead of the http.DefaultTransport, for pools/etc.
	DefaultTrip http.RoundTripper

	// DefaultClient should be used instead of using http.DefaultClient, for pools/etc.
	DefaultClient *http.Client

	// DefaultMemberWeight is the weight added to each member by default
	DefaultMemberWeight int
	// LocalMemberWeight is the weight assigned to each member that is AZ-local
	LocalMemberWeight int

	// ResponseModifierChain is a ProxyResponseModifierChain to handle sequences of modifications
	// use “ResponseModifierChain.Add()“ to add your own
	ResponseModifierChain ProxyResponseModifierChain

	// Materializers is a map of available PoolMaterializers
	Materializers = make(map[string]PoolMaterializer)
)
View Source
var (
	// RestartSelf is a niladic that will trigger a graceful restart of this process
	RestartSelf func()
	// IntSelf is a niladic that will trigger an interrupt of this process
	IntSelf func()
	// KillSelf is a niladic that will trigger a graceful shutdown of this process
	KillSelf func()
)
View Source
var (
	// Workers are a pool of workers
	Workers *workers.WorkerPool
	// AddWork queues up some work for workers
	AddWork func(workers.Work)
)
View Source
var (
	// CorsHandler is the global handler for CORS
	CorsHandler func(next http.Handler) http.Handler
)
View Source
var (
	// ErrorTemplate is an HTML template for returning errors
	ErrorTemplate *template.Template
)
View Source
var (
	// Handlers is a map of available Handlers (middlewares)
	Handlers = make(HandlerMap)
)
View Source
var (
	// MacroDictionary is a Dictionary for doing mcro
	MacroDictionary dictionary.Resolver
)
View Source
var (
	// SwitchMaps are maps of URLs parts and their IDs and/or endpoints
	SwitchMaps = mapmap.NewMapMap()
)
View Source
var (
	// TaskRegistry is for wrangling scheduled tasks
	TaskRegistry cronzilla.Wrangler
)
View Source
var (
	// VERSION is the internal code revision number
	VERSION string = "1.1.0+git"
)
View Source
var ZulipClient *zulip.Zulip

ZulipClient is a global Zulip client to use for messaging, or nil if not

Functions

func AccessLogHandler

func AccessLogHandler(next http.Handler) http.Handler

AccessLogHandler is a middleware that times how long requests takes, assembled an AccessLog, and logs accordingly

func AddMetrics

func AddMetrics(m map[string]map[string]interface{}, hc *health.Check) *health.Check

AddMetrics ranges over the supplied map, adding each as a Metric to the supplied Check

func AddStatuses

func AddStatuses(s *health.StatusRegistry, hc *health.Check) *health.Check

AddStatuses ranges over the supplied StatusRegistry, adding each as a Service to the supplied Check

func AuthoritativeDomainsHandler

func AuthoritativeDomainsHandler(next http.Handler) http.Handler

AuthoritativeDomainsHandler declines to handle requests that are not listed in "authoritativedomains" config

func Bootstrap

func Bootstrap()

Bootstrap assumes that the Conf object is all set, for now at least, builds the necessary subsystems and starts running.

Bootstrap doesn't return unless the server exits

func BootstrapChan

func BootstrapChan(closer chan struct{})

BootstrapChan assumes that the Conf object is all set, for now at least, builds the necessary subsystems and starts running.

BootstrapChan doesn't return unless the server exits or the passed chan is closed

func BuildPath

func BuildPath(path *Path, index int, router *mux.Router) (int, error)

BuildPath does the heavy lifting to build a single path (which may result in multiple paths, but that's just bookkeeping)

func BuildPaths

func BuildPaths(router *mux.Router) error

BuildPaths unmarshalls the paths config, creates handler chains, and updates the mux

func ChanBootstrap

func ChanBootstrap() chan error

ChanBootstrap assumes that the Conf object is all set, for now at least, builds the necessary subsystems and starts running.

ChanBootstrap returns quickly, and should be assumed running unless an error is received on the returned chan. ErrBootstrapDone should not be treated as a proper error, as it is returned if Bootstrap is complete (e.g. checkconfig or doc output)

func ConnectionCounterAdd

func ConnectionCounterAdd()

ConnectionCounterAdd atomically adds 1 to the ConnectionCounter

func ConnectionCounterGet

func ConnectionCounterGet() int64

ConnectionCounterGet atomically returns the current value of the ConnectionCounter

func ConnectionCounterRemove

func ConnectionCounterRemove()

ConnectionCounterRemove atomically adds -1 to the ConnectionCounter

func CopyHeaders

func CopyHeaders(dst http.Header, src http.Header)

CopyHeaders copies http headers from source to destination, it does not overide, but adds multiple headers

func CopyRequest

func CopyRequest(req *http.Request) *http.Request

CopyRequest provides a safe copy of a bodyless request into a new request

func CopyURL

func CopyURL(i *url.URL) *url.URL

CopyURL provides update safe copy by avoiding shallow copying User field

func DateFinisher added in v1.3.0

func DateFinisher(w http.ResponseWriter, r *http.Request)

DateFinisher is a Finisher that simply returns the current system datestamp as a string, for cache testing.

func DumpFinisher

func DumpFinisher(w http.ResponseWriter, r *http.Request)

DumpFinisher is a special finisher that reflects a ton of request output

func DumpHandler

func DumpHandler(h http.Handler) http.Handler

DumpHandler is a special handler that ships a ton of request output to DebugLog

func ECBDecrypt

func ECBDecrypt(b64key string, eb64ciphertext string) (plaintext []byte, err error)

ECBDecrypt takes a base64-encoded key and RawURLencoded-base64 ciphertext to decrypt, and returns the plaintext or an error. PKCS5 padding is trimmed as needed

func ECBEncrypt

func ECBEncrypt(b64key string, plaintext []byte) (b64ciphertext string, err error)

ECBEncrypt takes a base64-encoded key and a []byte, and returns the base64-encdoded ciphertext or an error. PKCS5 padding is added as needed

func EndpointDecider

func EndpointDecider(w http.ResponseWriter, r *http.Request)

EndpointDecider is a Finisher that inspects the “switchEndpointKey“ context to determine which materialized Pool should get the request. Requests for clusters that are not materialized, or not having the “clustername“ context value set will result in unrecoverable errors

func FileExists

func FileExists(filePath string) bool

FileExists returns true if the provided path exists, and is not a directory

func FlashEncoding

func FlashEncoding(src string) string

FlashEncoding returns a URL-encoded version of the provided string, with "+" additionally converted to "%2B"

func FolderExists

func FolderExists(filePath string) bool

FolderExists returns true if the provided path exists, and is a directory

func Forbidden

func Forbidden(w http.ResponseWriter, r *http.Request)

Forbidden is a Finisher that returns 403 for the requested Path

func GetErrorLog

func GetErrorLog(filename, prefix string, format, size, backups, age int) *log.Logger

GetErrorLog gets an error-type log

func GetLog

func GetLog(filename, prefix string, format, size, backups, age int) *log.Logger

GetLog gets a standard-type log

func GetLogOrDiscard

func GetLogOrDiscard(filename, prefix string, format, size, backups, age int) *log.Logger

GetLogOrDiscard gets a standard-type log, or discards the output

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID is returns a requestID from a context, or the empty string

func GetSwitchName

func GetSwitchName(request *http.Request) string

GetSwitchName is a function to return the switch name in a request's context, if present

func HandleFinisher

func HandleFinisher(handler string, path *Path) (http.HandlerFunc, error)

HandleFinisher takes a Finisher HandlerFunc name, and returns the function for it and nil, or nil and and error

func HandleGenericWrapper

func HandleGenericWrapper(code int, r *http.Request, rw *prw.PluggableResponseWriter, body []byte) bool

HandleGenericWrapper is essentially a noop for when no tempate or remote errorhandler is defined

func HandleHandler

func HandleHandler(handler string, hchain alice.Chain) (alice.Chain, error)

HandleHandler takes a handler name, and an existing chain, and returns a new chain or an error

func HandleReload

func HandleReload(name string, mfiles map[string]string)

HandleReload waits 5 seconds after being called, and then rebuilds the SwitchMaps

func HandleRemoteWrapper

func HandleRemoteWrapper(code int, r *http.Request, rw *prw.PluggableResponseWriter, body []byte) bool

HandleRemoteWrapper wraps errors (HTTP codes >= 400) in a pretty wrapper for client presentation, using a Worker to make a subrequest to an error-wrapping API

func HandleTemplateWrapper

func HandleTemplateWrapper(code int, r *http.Request, rw *prw.PluggableResponseWriter, body []byte) bool

HandleTemplateWrapper wraps errors (HTTP codes >= 400) in a pretty wrapper for client presentation, using a template

func InitConfig

func InitConfig() *viper.Viper

InitConfig creates an config, initialized with defaults and environment-set values, and returns it

func LoadConfig

func LoadConfig(configFilename string, v *viper.Viper) error

LoadConfig read the config file and returns a config object or an error

func LogInit

func LogInit() error

LogInit initializes all of the loggers based on Conf settings

func MinuteDelayer

func MinuteDelayer(w http.ResponseWriter, r *http.Request)

MinuteDelayer is a special finisher that waits for 60s before returning

func MinuteStreamer

func MinuteStreamer(w http.ResponseWriter, r *http.Request)

MinuteStreamer is a special finisher that writes the next number, once a secondish, for 60 iterations

func NewECBDecrypter

func NewECBDecrypter(b cipher.Block) cipher.BlockMode

NewECBDecrypter should never be used unless you know what you're doing

func NewECBEncrypter

func NewECBEncrypter(b cipher.Block) cipher.BlockMode

NewECBEncrypter should never be used unless you know what you're doing

func NewStickyPool added in v1.2.0

func NewStickyPool(poolName, cookieName, cookieType string, next http.Handler, opts ...roundrobin.LBOption) (*roundrobin.RoundRobin, error)

NewStickyPool returns a primed RoundRobin that honors pinning based on a cookie value

func OkFinisher

func OkFinisher(w http.ResponseWriter, r *http.Request)

OkFinisher is a Finisher that simply returns "Ok", for throughput testing.

func PoolLister

func PoolLister(w http.ResponseWriter, r *http.Request)

PoolLister is a finisher to list the pools

func PoolMemberAdder

func PoolMemberAdder(w http.ResponseWriter, r *http.Request)

PoolMemberAdder is a finisher to add a member to an existing pool

func PoolMemberLister

func PoolMemberLister(w http.ResponseWriter, r *http.Request)

PoolMemberLister is a finisher to list the members of an existing pool

func PoolMemberLoser

func PoolMemberLoser(w http.ResponseWriter, r *http.Request)

PoolMemberLoser is a finisher to remove a member from an existing pool

func PrettyPrint

func PrettyPrint(v interface{}) string

PrettyPrint returns the a JSONified version of the string, or %+v if that's not possible

func ReaderToString

func ReaderToString(r io.Reader) string

ReaderToString reads from a Reader into a Buffer, and then returns the string value of that

func RealAddr

func RealAddr(h http.Handler) http.Handler

RealAddr is a special handler to grab the most probable "real" client address

func Recoverer

func Recoverer(next http.Handler) http.Handler

Recoverer is a wrapping handler to make panic-capable handlers safer

func ReplaceURI

func ReplaceURI(r *http.Request, urlPath, requestURI string)

ReplaceURI standardizes the replacement of the Request.URL.Path and Request.RequestURI, which are squirrely at best.

func RequestErrorResponse

func RequestErrorResponse(r *http.Request, w http.ResponseWriter, Message string, code int)

RequestErrorResponse is the functional equivalent of ErrRequestError .WrappedResponse(..)

func RequestErrorString

func RequestErrorString(Request *http.Request, Message string) string

RequestErrorString is the functional equivalent of ErrRequestError .String()

func RequestIDFinisher added in v1.3.0

func RequestIDFinisher(w http.ResponseWriter, r *http.Request)

RequestIDFinisher is a Finisher that simply returns the current requestID a random number of times, for grind testing.

func ResponseHeaders

func ResponseHeaders(next http.Handler) http.Handler

ResponseHeaders is a simple piece of middleware that sets configured headers

func Restart

func Restart(w http.ResponseWriter, r *http.Request)

Restart signals the server to restart itself

func RouteIDInspectionHandler

func RouteIDInspectionHandler(next http.Handler) http.Handler

RouteIDInspectionHandler checks the Query params for a ROUTEID and shoves it into a cookie

func S3StreamProxyFinisher

func S3StreamProxyFinisher(w http.ResponseWriter, r *http.Request)

S3StreamProxyFinisher is a finisher that streams a POSTd file to an S3 bucket

func SetupHandler

func SetupHandler(next http.Handler) http.Handler

SetupHandler adds the RequestID and various other informatives to a request context

func Stack

func Stack(w http.ResponseWriter, r *http.Request)

Stack is a Finisher that dumps the current stack to the request

func StringIfCtx

func StringIfCtx(r *http.Request, name interface{}) string

StringIfCtx will return a non-empty string if the suppled Request has a Context.WithValue() of the specified name

func StringToCleanList added in v1.3.0

func StringToCleanList(in, sep string) []string

StringToCleanList splits 'in' using 'sep'arator, trims any leading/trailing space from each resulting string, and returns the list

func SwitchHandler

func SwitchHandler(next http.Handler) http.Handler

SwitchHandler adds URL switching information to the request context

func TestFinisher

func TestFinisher(w http.ResponseWriter, r *http.Request)

TestFinisher is a special finisher that outputs some detectables

func TrimPrefixURI

func TrimPrefixURI(r *http.Request, prefix string)

TrimPrefixURI standardizes the prefix trimming of the Request.URL.Path and Request.RequestURI, which are squirrely at best.

func URLCaptureHandler

func URLCaptureHandler(next http.Handler) http.Handler

URLCaptureHandler is an unchainable handler that captures the Hostname of the Pool Member servicing a request

func Unzip

func Unzip(src, dest string) error

Unzip takes a source zip, and a destination folder, and unzips source into dest, returning an error if appropriate

func Update

func Update(w http.ResponseWriter, r *http.Request)

Update signals the updater to update itself

func ValidateExtras

func ValidateExtras() []error

ValidateExtras runs through a list of referenced functions, and returns any errors they return. All functions will be run, so an array of errors may be returned

func WithRqID

func WithRqID(ctx context.Context, requestID string) context.Context

WithRqID returns a context which knows its request ID

func WithSessionID

func WithSessionID(ctx context.Context, sessionID string) context.Context

WithSessionID returns a context which knows its session ID

Types

type Access

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

Access is a type to provide binary validation of addresses, based on the contents of "Allow/Deny" rules.

func NewAccessFromStrings

func NewAccessFromStrings(allow, deny string) (*Access, error)

NewAccessFromStrings is the safest way to create a safe, valid Access type. The supplied "allow" and "deny" strings may be comma-delimited lists of IP addresses and/or CIDR networks.

func (*Access) AccessHandler

func (a *Access) AccessHandler(next http.Handler) http.Handler

AccessHandler is a handler that consults r.RemoteAddr and validates it against the Access type.

func (*Access) AddAddress

func (a *Access) AddAddress(address string, allow bool) error

AddAddress adds the supplied address to either the allow or deny lists, depending on the value of the suppled boolean. An error is returned if the supplied address cannot be parsed.

func (*Access) Validate

func (a *Access) Validate(address string) bool

Validate tests the supplied address against the Access type, returning boolean

type AccessLog

type AccessLog interface {
	// CommonLogFormat will return the contents as a CLF-compatible string. If combined is set, a "combined" CLF is included (adds referer and user-agent)
	CommonLogFormat(combined bool) string
	// Reset will empty out the contents of the access log
	Reset()
	// ResponseFiller adds response information to the AccessLog entry
	ResponseFiller(responseTime time.Time, responseDuration time.Duration, responseCode int, responseLength int)
	// RequestFiller adds request information to the AccessLog entry
	RequestFiller(r *http.Request)
}

AccessLog is an interface providing base logging, but allowing addons to extent it easily

type BasicAuth

type BasicAuth struct {
	// List of allowed users
	Users []string
	// contains filtered or unexported fields
}

BasicAuth wraps a handler requiring HTTP basic auth

func NewBasicAuth

func NewBasicAuth(source, realm string, users []string) *BasicAuth

NewBasicAuth takes a source, realm, and list of users, returning an initialized *BasicAuth

func NewVerifiedBasicAuth

func NewVerifiedBasicAuth(source, realm string, users []string) (*BasicAuth, error)

NewVerifiedBasicAuth takes a source, realm, and list of users, verifies the auth source, and returns an initialized *BasicAuth or an error

func (*BasicAuth) Authenticate

func (b *BasicAuth) Authenticate(username, password, realm string) bool

Authenticate takes a username, password, realm, and return bool if the authentication is positive

func (*BasicAuth) Load

func (b *BasicAuth) Load() error

Load prepares any pre-auth dancing, caching, etc. necessary

func (*BasicAuth) VerifySource

func (b *BasicAuth) VerifySource() error

VerifySource checks that the requested authentication source is valid, and accessible

type BodyByteLimit

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

BodyByteLimit is a Request.Body size limiter

func NewBodyByteLimit

func NewBodyByteLimit(limit int64) BodyByteLimit

NewBodyByteLimit returns an initialized BodyByteLimit

func (*BodyByteLimit) Handler

func (b *BodyByteLimit) Handler(next http.Handler) http.Handler

Handler limits the size of Request.Body

type CORS

type CORS struct {
	AllowCredentials string
	AllowMethods     string
	AllowHeaders     string
	MaxAge           string
	PrivateNetwork   string
	// contains filtered or unexported fields
}

CORS is an abstraction to handle CORS header nonsense. In order to keep origin comparisons as fast as possible, the expressions are pre-compiled, and thus need to either be added via AddOrigins() or supplied to NewCORSFromConfig().

func NewCORS

func NewCORS() *CORS

NewCORS returns an initialized CORS struct.

func NewCORSFromConfig

func NewCORSFromConfig(origins []string, conf map[string]string) (*CORS, error)

NewCORSFromConfig returns an initialized CORS struct from a list of origins and a config map

func (*CORS) AddOrigin

func (c *CORS) AddOrigin(origins []string) error

AddOrigin adds an origin expression to the CORS struct

func (*CORS) Handler

func (c *CORS) Handler(next http.Handler) http.Handler

Handler is a middleware that validates Origin request headers against a whitelist of expressions, and may change the response headers accordingly

func (*CORS) ResponseModifier

func (c *CORS) ResponseModifier(resp *http.Response) error

ResponseModifier is an oxy/forward opsetter to remove CORS headers from responses

func (*CORS) String

func (c *CORS) String() string

type CacheCluster added in v1.3.0

type CacheCluster struct {
	*cache.GroupCache
	// contains filtered or unexported fields
}

CacheCluster is our internal representation of GroupCache

func NewCacheCluster added in v1.3.0

func NewCacheCluster(address string, peers []string) *CacheCluster

NewCacheCluster should be called at most once, and returns an initialized CacheCluster

func (*CacheCluster) NewPageCache added in v1.3.0

func (cc *CacheCluster) NewPageCache(name string, cacheSize, maxItemSize int64, itemExpiration time.Duration, cacheControlHeader string) (*PageCache, error)

NewPageCache should be called at most once per unique "name", and returns an initialized PageCache

type Cert

type Cert struct {
	Domain   string
	Keyfile  string
	Certfile string
}

Cert encapsulated a Domain, the Keyfile, and a Certfile

type Compression

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

Compression is used to support GZIP compression of data en route to a client

func NewCompression

func NewCompression(contentTypes []string) *Compression

NewCompression returns a pointer to a Compression struct with the specified MIME-types baked in

func (*Compression) Handler

func (c *Compression) Handler(next http.Handler) http.Handler

Handler is a middleware to potentially GZIP-compress outgoing response bodies

type ConfigKey

type ConfigKey = string

ConfigKey is a string type for static config key name consistency

type ConsistentHashPool added in v1.2.0

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

ConsistentHashPool is a PoolManager that implements a consistent hash on a key to return the proper member consistently

func NewConsistentHashPool added in v1.2.0

func NewConsistentHashPool(source, key string, pool *Pool, next http.Handler) (*ConsistentHashPool, error)

NewConsistentHashPool returns a primed ConsistentHashPool

func NewConsistentHashPoolOpts added in v1.2.0

func NewConsistentHashPoolOpts(sourceKeys []hashSource, partitionCount, replicationFactor int, load float64, pool *Pool, next http.Handler) (*ConsistentHashPool, error)

NewConsistentHashPoolOpts exposes some internal tunables, but still returns a ConsistentHashPool

func (*ConsistentHashPool) Next added in v1.2.0

func (ch *ConsistentHashPool) Next() http.Handler

Next returns the specified next Handler

func (*ConsistentHashPool) NextServer added in v1.2.0

func (ch *ConsistentHashPool) NextServer() (*url.URL, error)

NextServer is an error-causing noop to implement PoolManager

func (*ConsistentHashPool) RemoveServer added in v1.2.0

func (ch *ConsistentHashPool) RemoveServer(u *url.URL) error

RemoveServer removes the specified member from the pool

func (*ConsistentHashPool) ServeHTTP added in v1.2.0

func (ch *ConsistentHashPool) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles its part of the request

func (*ConsistentHashPool) ServerWeight added in v1.2.0

func (ch *ConsistentHashPool) ServerWeight(u *url.URL) (int, bool)

ServerWeight is a noop to implement PoolManager

func (*ConsistentHashPool) Servers added in v1.2.0

func (ch *ConsistentHashPool) Servers() []*url.URL

Servers returns a list of member URLs

func (*ConsistentHashPool) UpsertServer added in v1.2.0

func (ch *ConsistentHashPool) UpsertServer(u *url.URL, options ...roundrobin.ServerOption) error

UpsertServer adds or updates the member to the pool

type CorsString

type CorsString = string

CorsString is a string type for static string consistency

type DebugTrip

type DebugTrip struct {
	// RTFunc is executed when RoundTrip() is called on a request.
	// It can be changed at any point to aid in changing conditions
	RTFunc func(*http.Request) (*http.Response, error)
}

DebugTrip is an http.RoundTripper with a pluggable core func to aid in debugging

func (*DebugTrip) RoundTrip

func (d *DebugTrip) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip is the Request executor

type ErrConfigurationError

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

ErrConfigurationError is returned when a debilitating configuration error occurs. If this is the initial configuration load, the program should exit. If this is a reload, the reload should abort and the known-working configuration should persist

func (ErrConfigurationError) Error

func (e ErrConfigurationError) Error() string

type ErrRequestError

type ErrRequestError struct {
	Request *http.Request
	Message string
}

ErrRequestError should be returned whenever an error is returned to a requestor. Care should be taken not to expose dynamic information inside the message. The request id will be automatically added to the message

func (ErrRequestError) Bytes

func (e ErrRequestError) Bytes() []byte

Bytes returns a []byte of the error

func (ErrRequestError) Error

func (e ErrRequestError) Error() string

Error returns a string of the error

func (ErrRequestError) String

func (e ErrRequestError) String() string

String returns a string of the error

func (ErrRequestError) WrappedResponse

func (e ErrRequestError) WrappedResponse(code int, w http.ResponseWriter)

WrappedResponse writes the templatized version of the error to a PRW

type Error

type Error string

Error is an error type

func (Error) Error

func (e Error) Error() string

Error returns the stringified version of Error

type ErrorWrapper

type ErrorWrapper struct {
	// E takes the error code, request, a PluggableResponseWriter, and the original body,
	// and returns boolean true IFF rw has been written to. E should not change
	// headers as they may be ignored.
	E func(code int, r *http.Request, rw *prw.PluggableResponseWriter, body []byte) bool
}

An ErrorWrapper is a struct to abstract error wrapping

func (*ErrorWrapper) Handler

func (e *ErrorWrapper) Handler(next http.Handler) http.Handler

Handler is the chainable handler that will wrap the error

type FinisherMap

type FinisherMap map[string]http.HandlerFunc

FinisherMap maps Finisher names to their HandlerFuncs

func (*FinisherMap) List

func (h *FinisherMap) List() []string

List returns the names of all of the Finishers

type FinisherSetupFunc added in v1.2.0

type FinisherSetupFunc func(*Path) (http.HandlerFunc, error)

FinisherSetupFunc is declared for Finishers that need exec-time setup checks

type ForbiddenPaths

type ForbiddenPaths struct {
	// Paths is a list of compiled Regexps, because speed
	Paths []*regexp.Regexp
}

ForbiddenPaths is a struct to assist in the expedient resolution of determining if a Request is destined to a forbidden path

func NewForbiddenPaths

func NewForbiddenPaths(paths []string) (*ForbiddenPaths, error)

NewForbiddenPaths takes a list of regexp-compatible strings, and returns the analogous ForbiddenPaths with compiled regexps, or an error if a regexp could not be compiled

func (*ForbiddenPaths) Handler

func (f *ForbiddenPaths) Handler(next http.Handler) http.Handler

Handler is a middleware that checks the request URI against regexps and 403's if match

type GenericResponse

type GenericResponse struct {
	Message string
	Code    int
}

GenericResponse is a Finisher that returns a possibly-wrapped response

func (*GenericResponse) Finisher

func (gr *GenericResponse) Finisher(w http.ResponseWriter, r *http.Request)

Finisher is a ... Finisher for the instantiated GenericResponse

type HMAC added in v1.2.1

type HMAC struct {

	// If non-zero, the Handler will enforce timestamp (UnixMilli) comparison to "now"
	Expiration time.Duration
	// If set, this will be the name of the query parameter holding the timestamp.
	// If unset, "expiration" is assumed.
	ExpirationField string
	// contains filtered or unexported fields
}

HMAC is a Handler that verifies the signature and possibly the timestamp of a request URL, and a Finisher that can sign URLs if so desired.

func NewHMAC added in v1.2.1

func NewHMAC(key, salt string, expiration time.Duration) *HMAC

NewHMAC returns an initialized Verifier. If expiration is unset, expirations are not enforced.

func (*HMAC) Handler added in v1.2.1

func (h *HMAC) Handler(next http.Handler) http.Handler

Handler does the HMAC verification, and possibly expiration calculation, of the request

func (*HMAC) ServeHTTP added in v1.2.1

func (h *HMAC) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is a Finisher to handle the request. It assumes that any preceding URI cruft has been stripped

type HTTPWork

type HTTPWork struct {
	Client       *http.Client
	Request      *http.Request
	ResponseChan chan interface{}
	// RetryCount is the number of times to retry Request if there is an error
	RetryCount int
	//RetryInterval is the duration between retries
	RetryInterval time.Duration
	//RetryHTTPErrors, if set, classifies HTTP responses >= 500 as errors for retry purposes
	RetryHTTPErrors bool
}

HTTPWork is a generic Work that can make HTTP requests

func (*HTTPWork) Return

func (h *HTTPWork) Return(rthing interface{})

Return is called response with results

func (*HTTPWork) Work

func (h *HTTPWork) Work() interface{}

Work is called to do work

type HandlerMap

type HandlerMap map[string]func(http.Handler) http.Handler

HandlerMap maps handler names to their funcs

func (*HandlerMap) List

func (h *HandlerMap) List() []string

List returns the names of all of the Handlers

type HealthCheckError

type HealthCheckError struct {
	PoolName    string
	URL         string
	StatusCode  int
	Prune       bool
	ErrorStatus HealthCheckStatus
	Add         PruneFunc
	Remove      PruneFunc
	Err         error
}

HealthCheckError is an error returned through the HealthCheck system

func (*HealthCheckError) Error

func (h *HealthCheckError) Error() string

Error returns the stringified version of the error

type HealthCheckResult

type HealthCheckResult struct {
	PoolName   string
	URL        string
	StatusCode int
	Prune      bool
	Add        PruneFunc
	Remove     PruneFunc
}

HealthCheckResult is a non-error returned through the HealthCheck system

type HealthCheckStatus

type HealthCheckStatus int

HealthCheckStatus is a specific int for HealthCheckStatus consts

const (
	Unknown HealthCheckStatus = iota
	Ok
	Warning
	Critical
)

Constants for HealthCheckStatuses

func StringToHealthCheckStatus

func StringToHealthCheckStatus(hc string) (HealthCheckStatus, error)

StringToHealthCheckStatus takes a string HealthCheckStatus and returns the HealthCheckStatus or ErrNoSuchHealthCheckStatus

func (HealthCheckStatus) String

func (i HealthCheckStatus) String() string

type HealthCheckWork

type HealthCheckWork struct {
	PoolName    string
	Member      string
	URL         string
	Prune       bool
	ErrorStatus HealthCheckStatus
	Add         PruneFunc
	Remove      PruneFunc
	// Return is an error, or the StatusCode int
	ReturnChan chan interface{}
}

HealthCheckWork is Work to run a HealthCheck

func (*HealthCheckWork) Return

func (h *HealthCheckWork) Return(rthing interface{})

Return consumes a Work result and slides it downthe return channel

func (*HealthCheckWork) Work

func (h *HealthCheckWork) Work() interface{}

Work executes the HealthCheck and returns HealthCheckResult or HealthCheckError

type JSONAccessLog

type JSONAccessLog struct {
	Timestamp     string `json:"timestamp"`
	Hostname      string `json:"hostname"`
	RemoteAddress string `json:"remoteaddr"`
	User          string `json:"user"`
	XForwardedFor string `json:"x-forwarded-for"`
	ClientIP      string `json:"clientip"`
	Method        string `json:"method"`
	Request       string `json:"request"`
	Status        string `json:"status"`
	Bytes         string `json:"bytes"`
	UserAgent     string `json:"user-agent"`
	Duration      string `json:"duration"`
	Referer       string `json:"referer"`
	Message       string `json:"message"`
	RequestID     string `json:"requestid"`
	Proto         string `json:"proto"`
	TLSVersion    string `json:"tlsversion"`
	// contains filtered or unexported fields
}

JSONAccessLog is an AccessLog uberstruct for JSONifying log data

func (*JSONAccessLog) CommonLogFormat

func (a *JSONAccessLog) CommonLogFormat(combined bool) string

CommonLogFormat will return the contents as a CLF-compatible string. If combined is set, a "combined" CLF is included (adds referer and user-agent)

func (*JSONAccessLog) RequestFiller

func (a *JSONAccessLog) RequestFiller(r *http.Request)

RequestFiller adds request information to the AccessLog entry

func (*JSONAccessLog) Reset

func (a *JSONAccessLog) Reset()

Reset will empty out the contents of the access log

func (*JSONAccessLog) ResponseFiller

func (a *JSONAccessLog) ResponseFiller(endtime time.Time, duration time.Duration, responseCode int, responseLength int)

ResponseFiller adds response information to the AccessLog entry

type Member

type Member struct {
	URL     *url.URL
	Address string
	AZ      string
	// contains filtered or unexported fields
}

Member is an attribute struct to describe a Pool Member

func (*Member) String added in v1.2.0

func (m *Member) String() string

String returns the Address of the Member

type NoopResponseWriter

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

NoopResponseWriter is a hack to support a Response with a status and headers, but no body. This is almost never what you want. Really.

func NewNoopResponseWriter

func NewNoopResponseWriter() NoopResponseWriter

NewNoopResponseWriter returns a NoopResponseWriter that you almost definitely do not want to use.

func (*NoopResponseWriter) Header

func (n *NoopResponseWriter) Header() http.Header

Header returns an http.Header

func (*NoopResponseWriter) Write

func (n *NoopResponseWriter) Write(bytes []byte) (int, error)

Write completely ignores whatever you've written, but lies and returns the size of whatever you wrote to it, and never an error

func (*NoopResponseWriter) WriteHeader

func (n *NoopResponseWriter) WriteHeader(statusCode int)

WriteHeader changes the response code

type PageCache added in v1.3.0

type PageCache struct {
	Name           string
	CacheSize      int64
	MaxItemSize    int64 // MaxItemSize > 0 is *roughly* the largest "page" "body" that will be cached
	ItemExpiration time.Duration
	// contains filtered or unexported fields
}

PageCache is a cache that is specific to caching responses

func (*PageCache) Handler added in v1.3.0

func (c *PageCache) Handler(next http.Handler) http.Handler

Handler is a JAR Handler that returns the cached response or waits until the response is returned and caches it if appropriate.

type Path

type Path struct {
	// Name is an optional "name" for the path. Will be output in some logs. If not set, will use an index number
	Name string
	// Path is a URI prefix to match
	Path string
	// Absolute declares if Path should be absolute instead of as a prefix
	Absolute bool
	// Allow
	Allow string
	// Deny
	Deny string
	// Host is a hostname or hostname-pattern to restrict this Path too
	Host string
	// Hosts is a list of hostnames or hostname-patterns to restrict this Path too.
	// Will result in one actual Path per entry, which is almost always fine.
	Hosts []string
	// Methods is a list of HTTP methods to restrict this path to
	Methods []string
	// Headers is a list of HTTP Request headers to restrict this path to
	Headers []string
	// Handlers is an ordered list of http.Handlers to apply
	Handlers []string
	// Pool is an actual Pool to handle the proxying. Mutually exclusive with Finisher
	Pool string
	// Finisher is the final handler. Mutually exclusive with Pool
	Finisher string
	// CacheName is the name of the cache to use, and should match a CachePool
	CacheName string
	// RateLimit each IP to these many requests/second. Also must have the "RateLimiter" handler, or it will be appended to the chain
	RateLimit float64
	// RateLimitPurge is a duration where a limit gets dumped
	RateLimitPurge time.Duration
	// RateLimitCollectOnly sets if the ratelimiter should only collect and log, versus enforce
	RateLimitCollectOnly bool
	// BodyByteLimit is the maximum number of bytes a Request.Body is allowed to be. It is poor form to set this unless the Path is terminated by
	// a finisher that will otherwise consume the Request.Body and possibly OOM and/or overuse disk space.
	BodyByteLimit int64
	// Redirect is a special Finisher. "%1" may be used to optionally denote the request path.
	// e.g. Redirect http://somewhereelse.com%1
	Redirect string
	// RedirectCode is an optional code to send as the redirect status
	RedirectCode int
	// RedirectHostMatch is a Perl-Compatible Regular Expression with grouping to apply to the Hostname, replacing $1,$2, etc. in “Redirect“
	RedirectHostMatch string
	// ReplacePath is used to replace the requested path with the target path
	ReplacePath string
	// StripPrefix is used to replace the requested path with one sans prefix
	StripPrefix string
	// BrowserExclusions is a list of browsers disallowed down this path, based on best-effort analysis of request headers
	BrowserExclusions []string
	// ForbiddenPaths is a list of path prefixes that will result in a 403, while traversing this path
	ForbiddenPaths []string
	// Timeout is a path-specific override of how long a request and response may take on this path
	Timeout time.Duration
	// BasicAuthRealm is the name of the HTTP Auth Realm on this Path. Need not be unique. Should not be empty.
	BasicAuthRealm string
	// BasicAuthSource is a URL to specify where HTTP Basic Auth information should come from (file://). Setting this forces auth
	BasicAuthSource string
	// BasicAuthUsers is a list of usernames allowed on this Path. Default is "all"
	BasicAuthUsers []string
	// ErrorMessage is a static message to respond with, if this path is executed
	ErrorMessage string
	// ErrorCode is the HTTP response code that will be returned with ErrorMessage, IFF ErrorMessage is set. Defaults to StatusOK
	ErrorCode int
	// HMACSigned is set if the URL will be signed and should be verified. Various Options need too be set in order for this to work.
	HMACSigned bool
	// Options is a horrible, brittle map[string]interface{} that some handlers or finishers
	// use for per-path configuration. Avoid if possible.
	Options PathOptions
}

Path is an extensible struct, detailing its configuration

type PathHandler

type PathHandler struct {
	Path    string
	Options PathOptions
}

PathHandler is a wrapping struct to inject the Path name, and any PathOptions into the Context

func (*PathHandler) Handler

func (p *PathHandler) Handler(next http.Handler) http.Handler

Handler is a middleware that injects the Path name, and any PathOptions into the Context

type PathOptions

type PathOptions map[string]interface{}

PathOptions is an MSI with a case-agnostic getter

func (*PathOptions) Get

func (p *PathOptions) Get(key string) interface{}

Get returns an interface{} if *key* matches, otherwise nil

func (*PathOptions) GetBool

func (p *PathOptions) GetBool(key string) bool

GetBool returns a bool value if *key* matches, otherwise false

func (*PathOptions) GetDuration added in v1.2.1

func (p *PathOptions) GetDuration(key string) (time.Duration, error)

GetDuration returns a Duration if *key* matches, otherwise zero-time

func (*PathOptions) GetInt64 added in v1.3.0

func (p *PathOptions) GetInt64(key string) (int64, error)

GetInt64 returns an int64 if *key* matches, otherwise zero

func (*PathOptions) GetString

func (p *PathOptions) GetString(key string) string

GetString returns a string if *key* matches, otherwise empty string

func (*PathOptions) GetStringSlice

func (p *PathOptions) GetStringSlice(key string) []string

GetStringSlice returns a []string if *key* matches, otherwise an empty []string

type PathReplacer

type PathReplacer struct {
	From string
	To   string
}

PathReplacer is a wrapping struct to replace the Request path

func (*PathReplacer) Handler

func (p *PathReplacer) Handler(next http.Handler) http.Handler

Handler is a middleware that replaces the Request path

type PathStripper

type PathStripper struct {
	Prefix string
}

PathStripper is a wrapping struct to remove the prefix from the Request path

func (*PathStripper) Handler

func (p *PathStripper) Handler(next http.Handler) http.Handler

Handler is a middleware that replaces the Request path

type Pool

type Pool struct {
	Config *PoolConfig

	// AddMember adds a URI to the loadbalancer. An error is returned if the URI doesn't parse properly
	AddMember func(string) error
	// RemoveMember removes a URI from the loadbalancer, but not from the member cache.
	// ErrNoSuchMemberError is returned if the requested member doesn't exist,
	// or another error if the URI provided doesn't parse properly.
	RemoveMember func(string) error
	// DeleteMember removes a URI from the entire Pool construct,
	// ErrNoSuchMemberError is returned if the requested member doesn't exist,
	// or another error if the URI provided doesn't parse properly.
	DeleteMember func(string) error
	// ListMembers returns a list of URIs for existing members
	ListMembers func() []*url.URL
	// contains filtered or unexported fields
}

Pool is a list of like-minded destinations

func NewPool added in v1.5.0

func NewPool(conf *PoolConfig) *Pool

NewPool returns a new, minimal, unmaterialized pool with the attached config

func (*Pool) GetMember

func (p *Pool) GetMember(u *url.URL) *Member

GetMember interacts with an internal cache, returning a Member from the cache or crafting a new one (and adding it to the cache)

func (*Pool) GetPool

func (p *Pool) GetPool() (http.Handler, error)

GetPool returns the materialized pool or an error. If the Pool has not been materialized, it does that.

func (*Pool) IsMaterialized

func (p *Pool) IsMaterialized() bool

IsMaterialized return boolean on whether the pool has been materialized or not

func (*Pool) Materialize

func (p *Pool) Materialize() (http.Handler, error)

Materialize returns a Handler that can represent the Pool.

Generally, you should call Pool.GetPool instead, so you can receive a pointer to the exist materialized pool if it exists, or it will Materialize it for you.

type PoolConfig

type PoolConfig struct {
	// Name is what you'd like to call this Pool
	Name string
	// Members is a list of URIs you'd like in the pool
	Members []string
	// Buffered refers to whether you'd like buffer all the requests, to possibly retry them in the even of a Member failure
	Buffered bool
	// BufferedFails is the number of failures to accept before giving up
	BufferedFails int
	// RemoveHeaders is a list of pool-specific headers to remove
	RemoveHeaders []string
	// ConsistentHashing is mutually exclusive to Sticky, and enables automatic distributions
	ConsistentHashing bool
	// ConsistentHashSources is a list of "header", "cookie", or "request".
	// For "header" and "cookie", it is paired with ConsistentHashName to choose which key from those maps is used.
	// For "request" it is paired with ConsistentHashName to choose from one of "remoteaddr", "host", and "url".
	// ConsistentHashSources ***must be balanced with ConsistentHashNames***.
	ConsistentHashSources []string
	// ConsistentHashNames is a list that sets the request part, header, or cookie name to pull the value from.
	// ConsistentHashSources ***must be balanced with ConsistentHashSources***.
	ConsistentHashNames []string
	// Sticky is mutually exclusive to ConsistentHashing, and enables cookie-based session routing
	Sticky bool
	// StickyCookieName overrides the name of the cookie used to handle sticky sessions
	StickyCookieName string
	// StickyCookieType allows for the setting of cookie values to "plain", "hash", or "aes"-encrypted.
	// The value of Conf.GetString(ConfigKeysStickyCookie) will be the salt for "hash" as-is, or the
	// base64-encoded key for "aes".
	StickyCookieType string
	// StripPrefix removes the specified string from the front of a URL before processing. Dupes Path.StripPrefix
	StripPrefix string
	// HealthCheckDisabled determines whether or not to healthcheck the members.
	HealthCheckDisabled bool
	// Healthcheck is a URI to check for health. Anything other than a 200 is bad.
	HealthCheckURI string
	// HealthCheckShotgun will disable the adaptive healthcheck scheduler, and fire all of them every interval
	HealthCheckShotgun bool
	// HealthCheckErrorStatus is a string mapping to a const HealthCheckStatus
	HealthCheckErrorStatus string
	// ReplacePath is used to replace the requested path with the target path
	ReplacePath string
	// Prune removes members that fail healthcheck, until they pass again
	Prune bool
	// EC2Affinity specifies whether an EC2-aware JAR should prefer a same-AZ member if available
	EC2Affinity bool
	// Options is a horrible, brittle map[string]interface{} that some PoolManagers
	// use for per-pool configuration. Avoid if possible.
	Options PoolOptions
}

PoolConfig is type exposing expected configuration for a pool, abstracted for passing around

type PoolID

type PoolID struct {
	Pool string
}

PoolID is a wrapping struct to inject the Pool name into the Context

func (*PoolID) Handler

func (p *PoolID) Handler(next http.Handler) http.Handler

Handler injects the Pool name into the Context

type PoolManager added in v1.2.0

type PoolManager interface {
	Servers() []*url.URL
	ServeHTTP(w http.ResponseWriter, req *http.Request)
	ServerWeight(u *url.URL) (int, bool)
	RemoveServer(u *url.URL) error
	UpsertServer(u *url.URL, options ...roundrobin.ServerOption) error
	NextServer() (*url.URL, error)
	Next() http.Handler
}

PoolManager is an interface to encompass oxy/roundrobin and our chpool

type PoolMaterializer added in v1.5.0

type PoolMaterializer func(*Pool) (http.Handler, error)

PoolMaterializer is a function responsible for materializing a Pool

type PoolOptions added in v1.2.0

type PoolOptions map[string]interface{}

PoolOptions is an MSI with a case-agnostic getter

func (*PoolOptions) Get added in v1.2.0

func (p *PoolOptions) Get(key string) interface{}

Get returns an interface{} if *key* matches, otherwise nil

func (*PoolOptions) GetBool added in v1.2.0

func (p *PoolOptions) GetBool(key string) bool

GetBool returns a bool value if *key* matches, otherwise false

func (*PoolOptions) GetFloat64 added in v1.2.0

func (p *PoolOptions) GetFloat64(key string) float64

GetFloat64 returns a float64 if *key* matches, otherwise -1

func (*PoolOptions) GetInt added in v1.2.0

func (p *PoolOptions) GetInt(key string) int

GetInt returns an int if *key* matches, otherwise -1

func (*PoolOptions) GetString added in v1.2.0

func (p *PoolOptions) GetString(key string) string

GetString returns a string if *key* matches, otherwise empty string

func (*PoolOptions) GetStringSlice added in v1.2.0

func (p *PoolOptions) GetStringSlice(key string) []string

GetStringSlice returns a []string if *key* matches, otherwise an empty []string

type Pools

type Pools struct {
	sync.RWMutex // Readers must RLock/RUnlock. Writers must Lock/Unlock

	// StopWatch will stop the monitoring of the pool members.
	StopWatch func()
	// contains filtered or unexported fields
}

Pools is a goro-safe map of Pool objects, and if interval > 0, will also healthcheck pool members, managing them accordingly.

func BuildPools

func BuildPools() (*Pools, error)

BuildPools unmarshalls the pools config, creates them, and updates the pool list ConfigPoolsHealthcheckInterval will set the healthcheck interval for pool members. Set to 0 to disable.

func NewPools

func NewPools(poolConfigs map[string]*PoolConfig, interval time.Duration) (*Pools, error)

NewPools creates a functioning Pools struct, initialized with the pools, and a healthcheck interval. Set the interval to 0 to disable healthchecks

func (*Pools) Exists

func (p *Pools) Exists(name string) bool

Exists returns bool if the named Pool exists

func (*Pools) Get

func (p *Pools) Get(name string) (*Pool, bool)

Get returns a Pool and a bool, given a name, from the Pools

func (*Pools) List

func (p *Pools) List() []string

List returns list of Pool names

func (*Pools) Merge

func (p *Pools) Merge(pools map[string]*Pool)

Merge adds-or-replaces the specified pools

func (*Pools) Replace

func (p *Pools) Replace(pools map[string]*Pool)

Replace does exactly that on the entire map of Pool

func (*Pools) Set

func (p *Pools) Set(name string, pool *Pool)

Set adds-or-replaces the named pool

type ProcessInfo

type ProcessInfo struct {
	Ctx context.Context
	// contains filtered or unexported fields
}

ProcessInfo is used to track information about ourselves. All member functions are safe to use across goros

func NewProcessInfo

func NewProcessInfo(pid int32) *ProcessInfo

NewProcessInfo returns an intialized ProcessInfo that has an interval set to 1 minute. Supply 0 as the pid to autodetect the running process' pid

func (*ProcessInfo) CPU

func (p *ProcessInfo) CPU() float64

CPU returns the current value of the CPU tracker, as a percent of total

func (*ProcessInfo) Memory

func (p *ProcessInfo) Memory() float64

Memory returns the current value of the process memory, as a percent of total

func (*ProcessInfo) SetInterval

func (p *ProcessInfo) SetInterval(i time.Duration)

SetInterval changes(?) the interval at which CPU slices are taken for comparison.

func (*ProcessInfo) UpdateCPU

func (p *ProcessInfo) UpdateCPU()

UpdateCPU loops while Ctx is valid, sampling our CPU usage every interval. This should generally only be called once, unless you know what you're doing

type ProxyResponseModifier

type ProxyResponseModifier func(resp *http.Response) error

ProxyResponseModifier is a type interface compatible with oxy/forward, to allow the proxied response to be modified at proxy-time, before the Handlers will see the response. This is of special importance for responses which need absolute mangling before a response is completed e.g. streaming/chunked responses

type ProxyResponseModifierChain

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

ProxyResponseModifierChain is an encapsulating type to chain multiple ProxyResponseModifier funcs for sequential execution as a single ProxyResponseModifier

func (*ProxyResponseModifierChain) Add

Add appends the provided ProxyResponseModifier to the ProxyResponseModifierChain

func (*ProxyResponseModifierChain) ToProxyResponseModifier

func (p *ProxyResponseModifierChain) ToProxyResponseModifier() ProxyResponseModifier

ToProxyResponseModifier returns a closure ProxyResponseModifier that will sequentially execute each encapsulated ProxyResponseModifier, discontinuing and returning an error as soon as one is noticed

type PruneFunc

type PruneFunc func(string) error

PruneFunc is a func that may add or remove Pool members

type RateLimiter

type RateLimiter struct {
	*limiter.Limiter
	// contains filtered or unexported fields
}

RateLimiter is a wrapper around limiter.Limiter

func NewRateLimiter

func NewRateLimiter(max float64, purgeDuration time.Duration) RateLimiter

NewRateLimiter returns a RateLimiter based on the specified max rps and purgeDuration

func NewRateLimiterCollector

func NewRateLimiterCollector(max float64, purgeDuration time.Duration) RateLimiter

NewRateLimiterCollector returns a RateLimiter based on the specified max rps and purgeDuration

func (*RateLimiter) Handler

func (rl *RateLimiter) Handler(next http.Handler) http.Handler

Handler is the middleware for the RateLimiter

type Redirect

type Redirect struct {
	URL    string
	Code   int
	Regexp *regexp.Regexp
}

Redirect is a Finisher that returns 301 for the requested Path

func (*Redirect) Finisher

func (rd *Redirect) Finisher(w http.ResponseWriter, r *http.Request)

Finisher is a ... Finisher for the instantiated Redirect

type S3Pool

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

S3Pool is an http.Handler that grabs a file from S3 and streams it back to the client

func NewS3Pool

func NewS3Pool(s3url string) (*S3Pool, error)

NewS3Pool returns an S3Pool or an error

func (*S3Pool) ServeHTTP

func (s3p *S3Pool) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is a proper http.Handler for authenticated S3 requests

type StatusFinisher

type StatusFinisher int

StatusFinisher is an abstracted type to dynamically provide Finishers of standard HTTP status codes

func (StatusFinisher) Finisher

func (sf StatusFinisher) Finisher(w http.ResponseWriter, r *http.Request)

Finisher writes a response of the set HTTP status code and text

type SuiteMap

type SuiteMap map[string]uint16

SuiteMap is a map of TLS cipher suites, to their hex code

var (
	// Ciphers is a map of ciphers from crypto/tls
	Ciphers SuiteMap

	// SslVersions is a map of SSL/TLS versions, mapped locally
	SslVersions = SuiteMap{
		"VersionSSL30": 0x0300,
		"VersionTLS10": 0x0301,
		"VersionTLS11": 0x0302,
		"VersionTLS12": 0x0303,
		"VersionTLS13": 0x0304,
	}
)

func NewSuiteMapFromCipherSuites

func NewSuiteMapFromCipherSuites(cipherSuites []*tls.CipherSuite) SuiteMap

NewSuiteMapFromCipherSuites takes a []*CipherSuite and creates a SuiteMap from it

func (*SuiteMap) AllSuites

func (s *SuiteMap) AllSuites() []uint16

AllSuites returns the hex codes for all of the cipher suites in an untrustable order

func (*SuiteMap) CipherListToSuites

func (s *SuiteMap) CipherListToSuites(list []string) ([]uint16, error)

CipherListToSuites takes an ordered list of cipher suite names, and returns their hex codes in the same order

func (*SuiteMap) List

func (s *SuiteMap) List() []string

List returns the names of the cipher suites in an untrustable order

func (*SuiteMap) Suite

func (s *SuiteMap) Suite(number uint16) string

Suite reverse lookups a suitename given the number

type TemplateError

type TemplateError struct {
	// ErrorCode is the string value of the error
	ErrorCode string
	// ErrorMessage is an optional message the template may optionally render
	ErrorMessage string
	// RedirectURL is a URL the template is advised to redirect to
	RedirectURL string
	// RedirectSeconds is the number of seconds the template is advised to wait
	// before executing the RedirectURL
	RedirectSeconds int
}

TemplateError is a static structure to pass into error-wrapping templates

type Timeout

type Timeout struct {
	Duration time.Duration
	Message  string
}

Timeout is a middleware that causes a 503 Service Unavailable message to be handed back if the timeout trips

func (*Timeout) Handler

func (t *Timeout) Handler(next http.Handler) http.Handler

Handler is the handler for Timeout

type ZulipWork added in v1.0.1

type ZulipWork struct {
	Client  *zulip.Zulip
	Stream  string
	Topic   string
	Message string
}

ZulipWork is a generic Work that can send Zulip notifications

func (*ZulipWork) Return added in v1.0.1

func (z *ZulipWork) Return(rthing interface{})

Return dumps the response. We don't care. :)

func (*ZulipWork) Work added in v1.0.1

func (z *ZulipWork) Work() interface{}

Work is called to do work

Directories

Path Synopsis
cmd
Package dictionary provides the Dictionary interface for abstraction, and a simple stringmap implementation called SimpleDict, used for macro definition and replacement.
Package dictionary provides the Dictionary interface for abstraction, and a simple stringmap implementation called SimpleDict, used for macro definition and replacement.
Package plugins provides support for Yaegi-style http.Handler "plugins", for use in JAR.
Package plugins provides support for Yaegi-style http.Handler "plugins", for use in JAR.
tests
Package watcher is used to keep an eye on file system events, and trigger actions when those events are of interest.
Package watcher is used to keep an eye on file system events, and trigger actions when those events are of interest.

Jump to

Keyboard shortcuts

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