Documentation ¶
Index ¶
- func CreateResponse(status int, body string) *http.Response
- func ServerHostName() string
- type BaseModule
- type Cache
- type CacheFetcher
- type CacheStats
- type ProxyModule
- type RequestContext
- func (ctx *RequestContext) EnsureWritableHeader(outgoing, incomming *http.Request)
- func (ctx *RequestContext) GetRequestCtxInfo(k string) string
- func (ctx *RequestContext) GetRequestCtxInfoKeys() []string
- func (ctx *RequestContext) GetSessionId() string
- func (ctx *RequestContext) SetRequestCtxInfo(k, v string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateResponse ¶
CreateResponse is a shorthand for making simple responses
func ServerHostName ¶
func ServerHostName() string
ServerHostName returns the os.Hostname as set by init()
Types ¶
type BaseModule ¶
type BaseModule struct{}
Generic Ozone ReverseProxy Module base implementation with empty functions Other modules can use this as a Base and then implement required functionality.
func (*BaseModule) Deinit ¶
func (appCtx *BaseModule) Deinit() error
func (*BaseModule) ModifyResponse ¶
func (appCtx *BaseModule) ModifyResponse(reqCtx *RequestContext, inReq *http.Request, resp *http.Response) error
func (*BaseModule) ProcessRequest ¶
func (appCtx *BaseModule) ProcessRequest(reqCtx *RequestContext, inReq *http.Request, proxyReq *http.Request) (*http.Response, error)
type Cache ¶
type Cache interface { // Set a cache value, potentially with a TTL Set(key []byte, value []byte, ttl time.Duration) error // Get the value of a key Get(key []byte) (value []byte, err error) // Get a value and fetch it in case of cache miss. GetAndStore(key []byte, fetcher CacheFetcher) (value []byte, err error) // Delete a key from the cache Delete(key []byte) // Clear the cache Clear() // Close the cache Close() error // Get statistics about cache usage. GetCacheStats() (stats *CacheStats) }
Cache defines the interface of a cache the reverse proxy can use to cache cross-request information.
type CacheFetcher ¶
CacheFetcher is used by the cache to retrieve a value for a key after a cache miss.
type CacheStats ¶
Statitics about cache usage.
type ProxyModule ¶
type ProxyModule interface { // ProcessRequest is called in sequence for each proxy module. If it returns (nil,nil) the // request (proxyReq) is passed down the chain to the next module until pushed to the HTTP Transport // Otherwise the http.Response is returned - or, if nil and err is non-nil: 500 Internal server error // inReq is provided for information containing the original request before module modification // reqCtx contains cross module context, a logger and a proxy global cache. ProcessRequest(reqCtx *RequestContext, inReq *http.Request, proxyReq *http.Request) (*http.Response, error) // ModifyResponse allows you to modify the response from the backend. // It's called in reverse module order. ModifyResponse(reqCtx *RequestContext, inReq *http.Request, resp *http.Response) error // Deinitilize Module, cleanup operations like close DB handles // Could be used to cleanup older connection during graceful configuration reloads Deinit() error }
Generic Ozone Reverse-Proxy Module
type RequestContext ¶
type RequestContext struct { // CtxCache provides cross-request caching CtxCache Cache // Log will attach request session id to all log output Log *log.Logger // contains filtered or unexported fields }
RequestContext is used to pass additional across the chain of rproxy modules.
func NewRequestContext ¶
NewRequestContext is used by the reverse proxy to create a new context for each request
func (*RequestContext) EnsureWritableHeader ¶
func (ctx *RequestContext) EnsureWritableHeader(outgoing, incomming *http.Request)
func (*RequestContext) GetRequestCtxInfo ¶
func (ctx *RequestContext) GetRequestCtxInfo(k string) string
GetRequestCtxInfo
func (*RequestContext) GetRequestCtxInfoKeys ¶
func (ctx *RequestContext) GetRequestCtxInfoKeys() []string
GetRequestCtxInfoKeys return the session info keys
func (*RequestContext) GetSessionId ¶
func (ctx *RequestContext) GetSessionId() string
GetSessionID returns the request session id
func (*RequestContext) SetRequestCtxInfo ¶
func (ctx *RequestContext) SetRequestCtxInfo(k, v string)