web

package
v3.24.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*options)

Option for the web server

func WithContextFiller

func WithContextFiller(contextFillers ...fillcontext.Filler) Option

WithContextFiller sets context fillers that are executed on every request context.

func WithCookieKeys

func WithCookieKeys(hashKey, blockKey []byte) Option

WithCookieKeys sets the cookie hash key and block key.

func WithDisableWarnings added in v3.16.1

func WithDisableWarnings(disable bool) Option

WithDisableWarnings configures if the webserver should emit misconfiguration warnings.

func WithLogIgnorePaths added in v3.8.4

func WithLogIgnorePaths(paths []string) Option

WithLogIgnorePaths silences log messages for a list of URLs.

func WithRedirectToHTTPS

func WithRedirectToHTTPS(from, to int) Option

WithRedirectToHTTPS redirects HTTP requests to HTTPS.

func WithRedirectToHost

func WithRedirectToHost(target string) Option

WithRedirectToHost redirects all requests to this host.

func WithStatic

func WithStatic(mount string, searchPaths ...string) Option

WithStatic sets the mount and search paths for static assets.

func WithTrustedProxies

func WithTrustedProxies(cidrs ...string) Option

WithTrustedProxies adds trusted proxies from which proxy headers are trusted.

type Registerer

type Registerer interface {
	RegisterRoutes(s *Server)
}

Registerer allows components to register their services to the web server.

func Redirect

func Redirect(path string, code int, location string) Registerer

Redirect returns a Registerer that redirects requests to the given path to the given location with the given code.

type Server

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

Server is the server.

func New

func New(ctx context.Context, opts ...Option) (*Server, error)

New builds a new server.

func (*Server) APIRouter

func (s *Server) APIRouter() *mux.Router

APIRouter returns the API router.

func (*Server) Prefix

func (s *Server) Prefix(prefix string) *mux.Route

Prefix returns a route for the given path prefix.

func (*Server) PrefixWithRedirect added in v3.16.2

func (s *Server) PrefixWithRedirect(prefix string) *mux.Route

PrefixWithRedirect will create a route ending in slash. Paths which coincide with the route, but do not end with slash, will be redirect to the slash ending route.

func (*Server) RootRouter

func (s *Server) RootRouter() *mux.Router

RootRouter returns the root router. In most cases the Router() should be used instead of the root router.

func (*Server) Router

func (s *Server) Router() *mux.Router

Router returns the main router.

func (*Server) ServeHTTP

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

ServeHTTP implements http.Handler.

func (*Server) Static

func (s *Server) Static(prefix string, fs http.FileSystem)

Static adds the http.FileSystem under the defined prefix.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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