vhosts

package module
v0.0.0-...-8c609f0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeAsGob

func EncodeAsGob(file string, v *Vhosts) error

EncodeAsGob encodes the given vhosts as gob and saves it to the given file

func GetVhostnames

func GetVhostnames(v ...*Vhosts) []string

GetVhostnames returns the hostnames list ( []string )

func Hash

func Hash(vhosts []Vhost) (string, error)

Hash returns the hash of the given vhosts list

func InitVHostDataFile

func InitVHostDataFile(path string) error

Init initializes the vhosts list from a file at the given path

func Initialize

func Initialize(listOfHostnames map[string]map[string]interface{})

Initialize initializes the vhosts list with some vhosts defaults map of hostname to middleware ( map[string]func(*fiber.Ctx) error )

func XVhost

func XVhost(vh *Vhosts) func(c *fiber.Ctx) error

Types

type FiberErrorHandler

type FiberErrorHandler func(*fiber.Ctx, error) error

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 GetVhosts

func GetVhosts() *Vhosts

GetVhosts returns the vhosts

func (*Vhosts) Add

func (v *Vhosts) Add(vhost Vhost) error

add adds a vhost to 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) Get

func (v *Vhosts) Get(hostname string) (Vhost, bool)

get returns the vhost with the given hostname

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

func (v *Vhosts) GetVhostnames() []string

GetVhostnames returns the hostnames list ( []string )

func (*Vhosts) InitializeHandlerSpace

func (v *Vhosts) InitializeHandlerSpace()

func (*Vhosts) Load

func (v *Vhosts) Load(file string) error

Load loads the vhosts from the given file

func (*Vhosts) NumberOfVhosts

func (v *Vhosts) NumberOfVhosts() int

NumberOfVhosts returns the length of the vhosts list

func (*Vhosts) ReloadHandlers

func (v *Vhosts) ReloadHandlers() error

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

func (v *Vhosts) Remove(hostname string) error

remove removes the vhost with the given hostname

func (*Vhosts) RemoveErrorHandler

func (v *Vhosts) RemoveErrorHandler(errorHandlerTag string) error

RemoveErrorHandler removes the error handler with the given error handler tag ( string ) and return error if it doesn't exist

func (*Vhosts) RemoveHandler

func (v *Vhosts) RemoveHandler(handlerTag string) error

RemoveHandler removes the handler with the given handler tag ( string ) and return error if it doesn't exist

func (*Vhosts) Save

func (v *Vhosts) Save(file string) error

Save saves the vhosts to the given file

func (*Vhosts) SetErrorHandler

func (v *Vhosts) SetErrorHandler(hostname string, errorHandler FiberErrorHandler) error

SetErrorHandler sets the error handler for the given hostname

func (*Vhosts) SetErrorHandlerByTag

func (v *Vhosts) SetErrorHandlerByTag(hostname, tag string) error

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

func (v *Vhosts) SetHandlerByTag(hostname, tag string) error

SetHandlerByTag sets the handler for the given hostname

Jump to

Keyboard shortcuts

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