webserver

package
v0.0.0-...-91c0e42 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address           string     `json:"address"`
	RootRedirect      string     `json:"root_redirect"`
	OnlyHTTPSRootLink bool       `json:"only_https_rootlink"`
	PermanentRedirect bool       `json:"permanent_redirect"`
	APITokenHash      string     `json:"api_token_hash"`
	SessionStoreKey   string     `json:"session_store_key"`
	TLS               *ConfigTLS `json:"tls"`
}

Config contains the configuration values for the WebServer.

type ConfigTLS

type ConfigTLS struct {
	Use      bool   `json:"use"`
	CertFile string `json:"cert_file"`
	KeyFile  string `json:"key_file"`
}

ConfigTLS contains the configuration values for TLS encryption for the WebServer.

type RateLimitManager

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

A RateLimitManager maintains all rate limiters for each connection.

func NewRateLimitManager

func NewRateLimitManager() *RateLimitManager

NewRateLimitManager creates a new instance of RateLimitManager.

func (*RateLimitManager) GetHandler

func (rlm *RateLimitManager) GetHandler(limit time.Duration, burst int) routing.Handler

GetHandler returns a new afsthttp-routing handler which manages per-route and connection- based rate limiting. Rate limit information is added as 'X-RateLimit-Limit', 'X-RateLimit-Remaining' and 'X-RateLimit-Reset' headers. This handler aborts the execution of following handlers when rate limit is exceed and throws a json error body in combination with a 429 status code.

type WebServer

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

A WebServer handles the REST API connections.

func NewWebServer

func NewWebServer(conf *Config, db database.Middleware, authProvider auth.Provider) (*WebServer, error)

NewWebServer creates a new instance of WebServer and registers all set request handlers.

func (*WebServer) ListenAndServeBlocking

func (ws *WebServer) ListenAndServeBlocking() error

ListenAndServeBlocking starts listening for HTTP requests and serving responses to the specified address in the config. The server will run in TLS mode when set in the config. The startet event loop will block the current go routine.

Jump to

Keyboard shortcuts

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