webServer

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateNotStarted        = "NotStarted"
	StateStarted           = "Started"
	StateShutdownRequested = "ShutdownRequested"
	StateShutdownCompleted = "ShutdownCompleted"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FastHttpServer

type FastHttpServer struct {
	Router       *router.Router
	Server       fasthttp.Server
	BindPort     int
	EnableIpv6   bool
	BlockOnStart bool // Should we block on start or not
	// contains filtered or unexported fields
}

func NewLocalServer

func NewLocalServer() *FastHttpServer

NewLocalServer creates a basic new local server and returns it. It can then be modified and started (or started as it is)

func (*FastHttpServer) AddMiddlewareSetToSet

func (s *FastHttpServer) AddMiddlewareSetToSet(mwSet MiddlewareSet, name string)

AddMiddlewareSetToSet adds all the middlewares of one set to another set. Useful when you want to have some base middleware sets and you want to create others with those middlewares as common with the new ones

func (*FastHttpServer) AddMiddlewareToSet

func (s *FastHttpServer) AddMiddlewareToSet(m Middleware, name string)

AddMiddlewareToSet will add a middleware to a single middleware set of a given name If a middleware set of that name does not exist, then one will be created.

func (*FastHttpServer) EraseMiddlewares

func (s *FastHttpServer) EraseMiddlewares()

EraseMiddlewares removes all the middlewares from the server so that you can create a whole new set from scratch

func (*FastHttpServer) GetMiddlewareSet

func (s *FastHttpServer) GetMiddlewareSet(name string) MiddlewareSet

GetMiddlewareSet returns the middleware set by the given name. If there is no middleware set by that name, a blank one is returned instead

func (*FastHttpServer) ListMiddlewareNames

func (s *FastHttpServer) ListMiddlewareNames() []string

ListMiddlewareNames is supposed to return the list of middlewares in the server

func (*FastHttpServer) Start

func (s *FastHttpServer) Start() appError.Typ

Start starts the web server according to given parameters

func (*FastHttpServer) Stop

func (s *FastHttpServer) Stop()

Stop will stop the server. It does so by setting the current state. The manager will notice the change and stop the server gracefully

func (*FastHttpServer) WithMiddlewareSet

func (s *FastHttpServer) WithMiddlewareSet(name string, handler fasthttp.RequestHandler) fasthttp.RequestHandler

WithMiddlewareSet will return a request handler which would contain all the middlewares given by name applied to the handler supplied to this function.

type Middleware

type Middleware func(handler fasthttp.RequestHandler) fasthttp.RequestHandler

type MiddlewareSet

type MiddlewareSet []Middleware

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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