server

package
v0.0.0-...-dc37515 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(r *http.Request) logrus.FieldLogger

GetLogger returns the logger from the request context.

func GetLoggerOrDefault

func GetLoggerOrDefault(r *http.Request, l logrus.FieldLogger) logrus.FieldLogger

GetLoggerOrDefault returns the logger from the request context, or the given default one if it is not found.

func Wrap

func Wrap(h http.Handler, middlewares ...negroni.Handler) http.Handler

Wrap wraps a http handler with middlewares.

func WrapF

func WrapF(h http.HandlerFunc, middlewares ...negroni.Handler) http.Handler

WrapF wraps a http handler function with middlewares.

Types

type BaseURL

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

BaseURL represents the server's base url.

func ParseBaseURL

func ParseBaseURL(rawurl string) (*BaseURL, error)

ParseBaseURL creates a new BaseURL by parsing the string form.

func (*BaseURL) Path

func (b *BaseURL) Path(parts ...string) string

Path creates a new url from the base url by appending items to its path.

type Route

type Route struct {
	Method  string
	Path    string
	Handler http.Handler
}

Route represents a set of method, path and http.Handler.

func PrefixRoutes

func PrefixRoutes(prefix string, routes []Route) []Route

PrefixRoutes adds prefixes to the routes.

type Router

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

Router represents an abstract http router.

func NewRouter

func NewRouter() *Router

NewRouter creates a router.

func (*Router) Add

func (r *Router) Add(routes ...Route) *Router

Add adds routes to the router.

func (*Router) Delete

func (r *Router) Delete(path string, handler http.Handler) *Router

func (*Router) DeleteF

func (r *Router) DeleteF(path string, handler http.HandlerFunc) *Router

func (*Router) Get

func (r *Router) Get(path string, handler http.Handler) *Router

func (*Router) GetF

func (r *Router) GetF(path string, handler http.HandlerFunc) *Router

func (*Router) Handle

func (r *Router) Handle(method, path string, handler http.Handler) *Router

Handle adds a handler to the router.

func (*Router) Handler

func (r *Router) Handler() http.Handler

Handler returns the underlying http.Handler of the router.

func (*Router) Head

func (r *Router) Head(path string, handler http.Handler) *Router

func (*Router) HeadF

func (r *Router) HeadF(path string, handler http.HandlerFunc) *Router

func (*Router) Patch

func (r *Router) Patch(path string, handler http.Handler) *Router

func (*Router) PatchF

func (r *Router) PatchF(path string, handler http.HandlerFunc) *Router

func (*Router) Post

func (r *Router) Post(path string, handler http.Handler) *Router

func (*Router) PostF

func (r *Router) PostF(path string, handler http.HandlerFunc) *Router

func (*Router) Put

func (r *Router) Put(path string, handler http.Handler) *Router

func (*Router) PutF

func (r *Router) PutF(path string, handler http.HandlerFunc) *Router

type Server

type Server struct {
	HTTPS struct {
		LetsEncrypt struct {
			Directory string
			WhiteList []string
		}
		Certificate struct {
			Certfile string
			Keyfile  string
		}
	}
	// contains filtered or unexported fields
}

Server is the main application server.

func New

func New(logger logrus.FieldLogger, addr string, panicFormatter negroni.PanicFormatter) *Server

New creates a new server.

func (*Server) CreateHTTPServer

func (s *Server) CreateHTTPServer() *http.Server

CreateHTTPServer creates a http.Server from the application server.

This server is fully configured and it is ready to be started.

func (*Server) IsHTTPS

func (s *Server) IsHTTPS() bool

IsHTTPS tells if the server is configured to use HTTPS.

func (*Server) Router

func (s *Server) Router() *Router

Router returns the server's router.

func (*Server) Start

func (s *Server) Start() error

Start starts an http server that is created from the application server.

func (*Server) Use

func (s *Server) Use(middlewares ...negroni.Handler)

Use adds middlewares to the end of the server's middleware chain.

Jump to

Keyboard shortcuts

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