web

package
v0.0.0-...-5352646 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(err error, c echo.Context)

ErrorHandler is an echo.HTTPErrorHandler.

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.

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

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

Group creates a sub group.

func (*Server) RootGroup

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

RootGroup creates a new Echo router group with prefix and optional group-level middleware on the root Server.

func (*Server) Routes

func (s *Server) Routes() []*echo.Route

Routes returns the defined routes.

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, middleware ...echo.MiddlewareFunc)

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