web

package
v3.8.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNoopLogger

func NewNoopLogger() echo.Logger

NewNoopLogger returns an echo.Logger that discards all log messages.

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 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) DELETE

func (s *Server) DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

DELETE registers a DELETE handler at path.

func (*Server) GET

func (s *Server) GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

GET registers a GET handler at path.

func (*Server) Group

func (s *Server) Group(prefix string, middleware ...echo.MiddlewareFunc) *echo.Group

Group creates a sub group.

func (*Server) HEAD

func (s *Server) HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

HEAD registers a HEAD handler at path.

func (*Server) POST

func (s *Server) POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

POST registers a POST handler at path.

func (*Server) Prefix

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

Prefix returns a route for the given path prefix.

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