Documentation ¶
Index ¶
- func Base64Encode(data []byte) string
- func EncodeAsGob(file string, v *Vhosts) error
- func GetVhostnames(v ...*Vhosts) []string
- func Hash(vhosts []Vhost) (string, error)
- func InitVHostDataFile(path string) error
- func Initialize(listOfHostnames map[string]map[string]interface{})
- func VhostMiddleware(c *fiber.Ctx) error
- func XVhost(vh *Vhosts) func(c *fiber.Ctx) error
- type FiberErrorHandler
- type FiberHandler
- type Vhost
- type Vhosts
- func (v *Vhosts) Add(vhost Vhost) error
- func (v *Vhosts) AddErrorHandler(errorHandlerTag string, errorHandler FiberErrorHandler) error
- func (v *Vhosts) AddHandler(handlerTag string, handler FiberHandler) error
- func (v *Vhosts) Get(hostname string) (Vhost, bool)
- func (v *Vhosts) GetErrorHandler(errorHandlerTag string) (FiberErrorHandler, bool)
- func (v *Vhosts) GetHandler(handlerTag string) (FiberHandler, bool)
- func (v *Vhosts) GetVhostnames() []string
- func (v *Vhosts) InitializeHandlerSpace()
- func (v *Vhosts) Load(file string) error
- func (v *Vhosts) Lock()
- func (v *Vhosts) NumberOfVhosts() int
- func (v *Vhosts) RLock()
- func (v *Vhosts) RUnlock()
- func (v *Vhosts) ReloadHandlers() error
- func (v *Vhosts) Remove(hostname string) error
- func (v *Vhosts) RemoveErrorHandler(errorHandlerTag string) error
- func (v *Vhosts) RemoveHandler(handlerTag string) error
- func (v *Vhosts) Save(file string) error
- func (v *Vhosts) SetErrorHandler(hostname string, errorHandler FiberErrorHandler) error
- func (v *Vhosts) SetErrorHandlerByTag(hostname, tag string) error
- func (v *Vhosts) SetHandler(hostname string, handler FiberHandler) error
- func (v *Vhosts) SetHandlerByTag(hostname, tag string) error
- func (v *Vhosts) Unlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Encode ¶
Base64Encode encodes the given data as base64 encoded string
func EncodeAsGob ¶
EncodeAsGob encodes the given vhosts as gob and saves it to the given file
func GetVhostnames ¶
GetVhostnames returns the hostnames list ( []string )
func InitVHostDataFile ¶
Init initializes the vhosts list from a file at the given path
func Initialize ¶
Initialize initializes the vhosts list with some vhosts defaults map of hostname to middleware ( map[string]func(*fiber.Ctx) error )
func VhostMiddleware ¶
func VhostMiddleware(c *fiber.Ctx) error
Vhost middleware for fiber app to handle virtual hosts based on hostname and path ( if any ). It sets the handler and error handler for the vhost based on the hostname and path ( if any )
Types ¶
type FiberErrorHandler ¶
FiberErrorHandler is the error handler for the vhost middleware
type FiberHandler ¶
type FiberHandler func(*fiber.Ctx) error
FiberHandler is the handler for the vhost middleware
type Vhost ¶
type Vhost struct { Hostname string // hostname is the hostname of the vhost Path string // path is the path of the vhost WebsiteID string // websiteID is the websiteID of the vhost ErrorHandler FiberErrorHandler // errorHandler is the error handler for the vhost Handler FiberHandler // middleware is the middleware for the vhost LastModified int64 // lastModified is the last modified time of the vhost }
Vhost is a virtual host
func NewVhost ¶
func NewVhost(hostname, path, websiteID string, handler FiberHandler, errorHandler FiberErrorHandler) Vhost
NewVhost returns a new vhost with the given hostname, path, websiteID and middleware
type Vhosts ¶
type Vhosts struct { // vhosts is the list of vhosts Vhosts []Vhost // LastModified is the last modified time of the vhosts file LastModified int64 // Version is the version of the vhosts file ( quick way to check if the vhosts file has changed ) Version int64 // Checksum is the checksum of the vhosts file ( quick way to check if the vhosts file has changed ) Checksum string // contains filtered or unexported fields }
vhosts contains all the vhosts protected by mutex lock for concurrent access safety
var Vhs *Vhosts
vhosts is the vhosts list
func (*Vhosts) AddErrorHandler ¶
func (v *Vhosts) AddErrorHandler(errorHandlerTag string, errorHandler FiberErrorHandler) error
AddErrorHandler adds an error handler to the error handlers list for the given error handler tag ( string )
func (*Vhosts) AddHandler ¶
func (v *Vhosts) AddHandler(handlerTag string, handler FiberHandler) error
AddHandler adds a handler to the handlers list for the given handler tag ( string )
func (*Vhosts) GetErrorHandler ¶
func (v *Vhosts) GetErrorHandler(errorHandlerTag string) (FiberErrorHandler, bool)
GetErrorHandler returns the error handler for the given error handler tag ( string )
func (*Vhosts) GetHandler ¶
func (v *Vhosts) GetHandler(handlerTag string) (FiberHandler, bool)
GetHandler returns the handler for the given handler tag ( string )
func (*Vhosts) GetVhostnames ¶
GetVhostnames returns the hostnames list ( []string )
func (*Vhosts) InitializeHandlerSpace ¶
func (v *Vhosts) InitializeHandlerSpace()
func (*Vhosts) NumberOfVhosts ¶
NumberOfVhosts returns the length of the vhosts list
func (*Vhosts) ReloadHandlers ¶
ReloadHandlers reloads the handlers for each vhost based on the path var. It sets a default handler for each vhost if the path var is empty
func (*Vhosts) RemoveErrorHandler ¶
RemoveErrorHandler removes the error handler with the given error handler tag ( string ) and return error if it doesn't exist
func (*Vhosts) RemoveHandler ¶
RemoveHandler removes the handler with the given handler tag ( string ) and return error if it doesn't exist
func (*Vhosts) SetErrorHandler ¶
func (v *Vhosts) SetErrorHandler(hostname string, errorHandler FiberErrorHandler) error
SetErrorHandler sets the error handler for the given hostname
func (*Vhosts) SetErrorHandlerByTag ¶
SetErrorHandlerByTag sets the error handler for the given hostname
func (*Vhosts) SetHandler ¶
func (v *Vhosts) SetHandler(hostname string, handler FiberHandler) error
SetHandler sets the handler for the given hostname
func (*Vhosts) SetHandlerByTag ¶
SetHandlerByTag sets the handler for the given hostname