server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout                = 30 * time.Second
	ServerGracefulShutdownTimeout = 5 * time.Second
)

Variables

View Source
var ErrMatchingTarget = fmt.Errorf("no matching target found")

Functions

This section is empty.

Types

type Listener

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

Listener is the Listen server.

func NewListener

func NewListener(ctx context.Context, cfg *config.Listener, handler http.Handler) (*Listener, error)

func (*Listener) Shutdown

func (l *Listener) Shutdown(ctx context.Context)

Shutdown stops the listener.

func (*Listener) Start

func (l *Listener) Start(ctx context.Context)

Start starts the listen server.

type Listeners

type Listeners map[string]*Listener

Listeners holds a map of Listeners.

func NewListeners

func NewListeners(cfg config.Listeners, handler http.Handler) (Listeners, error)

NewListeners creates new listeners.

func (Listeners) Start

func (ls Listeners) Start()

Start starts the server listeners.

func (Listeners) Stop

func (ls Listeners) Stop()

Stops stops the server listeners.

type Server

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

Server is the reverse proxy cache.

func NewServer

func NewServer(cfg *config.Configuration, pdr provider.Provider, httpcache *cache.HttpCache) (*Server, error)

NewServer creates a new configured server.

func (*Server) Await

func (s *Server) Await()

Await blocks until SIGTERM or Stop() is called.

func (*Server) CacheConfigHandler

func (s *Server) CacheConfigHandler(w http.ResponseWriter, r *http.Request)

CacheConfigHandler renders the current cache config.

func (*Server) CacheConfigUpdateHandler

func (s *Server) CacheConfigUpdateHandler(w http.ResponseWriter, r *http.Request)

CacheConfigHandler renders the current cache config.

func (*Server) CacheFlushHandler

func (s *Server) CacheFlushHandler(w http.ResponseWriter, r *http.Request)

CacheFlushHandler handles the DELETE request to flush all keys from the cache.

func (*Server) CacheInvalidateHandler added in v0.2.0

func (s *Server) CacheInvalidateHandler(w http.ResponseWriter, r *http.Request)

CacheInvalidateHandler handles the DELETE request to invalidate the provided key in the cache. When running in a cluster, this does not broadcast to other kache instances.

func (*Server) CacheKeyPurgeHandler

func (s *Server) CacheKeyPurgeHandler(w http.ResponseWriter, r *http.Request)

CacheKeyPurgeHandler handles a PURGE request and deletes the given key from the cache. The cache key is obtained from a custom request header 'X-Purge-Key'. When running in a cluster a invalidation signal gets broadcasted to other instances.

func (*Server) CacheKeysHandler

func (s *Server) CacheKeysHandler(w http.ResponseWriter, r *http.Request)

CacheKeysHandler renders all cache keys in JSON format.

func (*Server) Director

func (s *Server) Director() func(req *http.Request)

Director matches the incoming request to a specific target and sets the request object to be sent to the matched upstream server.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown the server, gracefully. Should be defered after Start().

func (*Server) Start

func (s *Server) Start(ctx context.Context)

Start starts the server.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server.

type Target

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

Target holds information about the upstream target.

func NewTarget

func NewTarget(cfg *config.Upstream) (*Target, error)

NewTarget creates a new upstream target.

type Targets

type Targets []*Target

Targets holds an array of targets.

func NewTargets

func NewTargets(upstreamsConfig config.Upstreams) (Targets, error)

NewTargets creates new upstream targets.

func (Targets) MatchTarget

func (tgs Targets) MatchTarget(req *http.Request) (*Target, bool)

MatchTarget matches a given request to a registered route.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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