Documentation ¶
Overview ¶
Package server is a configurable webserver with pre-defined hooks.
Index ¶
- Constants
- Variables
- func Caches() ([]cache.Manager, error)
- func Config() (interface{}, error)
- func Databases() ([]query.Builder, error)
- func Dir() (string, error)
- func FrontendConfigConverter(cfg interface{}, addChildren ...bool) map[string]interface{}
- func JWT() (*jwt.Token, error)
- func New(config interface{}) error
- func Router() (router.Manager, error)
- func SetJWT(t *jwt.Token) error
- func Start() error
- func Stop() error
- func Translation() (translation.Manager, error)
- type Configuration
- type ConfigurationApp
- type ConfigurationAuth
- type ConfigurationCache
- type ConfigurationMail
- type ConfigurationRouter
- type ConfigurationWebserver
- type I18n
- type Orm
- type PatternSource
- type Route
Constants ¶
const ( ROUTER = iota + 1 DB CACHE TRANSLATION )
Variables ¶
var ( ErrInit = errors.New("server: is not loaded") ErrJWT = errors.New("server: jwt is not defined") )
Error messages
var (
ErrConfig = "server: config %#v is mandatory"
)
Error messages.
Functions ¶
func Caches ¶
Caches of the webserver. Error will return if the server instance was not created yet.
func Config ¶
func Config() (interface{}, error)
Config will return the given configuration. Error will return if the server instance was not created yet.
func Databases ¶
Databases of the webserver. Error will return if the server instance was not created yet.
func FrontendConfigConverter ¶
FrontendConfigConverter will return all configuration fields as map, if the tag `frontend` exists and the its not the skip tag. Works with embedded fields. If the `frontend` tag exists on a struct, all struct fields will be added, except if a skip tag was used on one or more fields. The the json keys will be first letter to lower.
func New ¶
func New(config interface{}) error
New creates a new server instance with the given configuration.
func Router ¶
Router of the webserver. Error will return if the server instance was not created yet.
func SetJWT ¶
SetJWT to the webserver. This is needed because the jwt token claim must be set-able to guarantee a customization.
func Start ¶
func Start() error
Start the webserver. Error will return if the server instance was not created yet.
func Stop ¶
func Stop() error
Stop the webserver. Error will return if the server instance was not created yet.
func Translation ¶
func Translation() (translation.Manager, error)
Translation of the webserver. Error will return if the server instance was not created yet.
Types ¶
type Configuration ¶
type Configuration struct { Webserver ConfigurationWebserver Databases []query.Config Mail ConfigurationMail Caches []ConfigurationCache }
Configuration for the Webserver. This configuration can be simple embedded in your application config.
func ServerConfig ¶
func ServerConfig() (Configuration, error)
ServerConfig will return the server.Configuration. Error will return if the server instance was not created yet.
type ConfigurationApp ¶
type ConfigurationAuth ¶
type ConfigurationAuth struct { Providers map[string]map[string]interface{} `frontend:""` JWT jwt.Config BcryptCost int `json:"bcryptCost"` AllowedFailedLogin int `json:"allowedFailedLogins"` // 0 = infinity LockDuration string `json:"lockDuration"` InactiveDuration string `json:"inactiveDuration"` TokenDuration string `json:"tokenDuration"` RefreshTokenDuration string `json:"refreshTokenDuration"` }
Auth configuration
type ConfigurationCache ¶
type ConfigurationMail ¶
Mail configuration
type ConfigurationRouter ¶
type ConfigurationRouter struct { Provider string Favicon string Directories []PatternSource Files []PatternSource CreateDBRoutes bool }
Router configuration
type ConfigurationWebserver ¶
type ConfigurationWebserver struct { App ConfigurationApp Domain string `frontend:""` HTTPPort int FrontendConfigFile string Translation I18n Auth ConfigurationAuth Router ConfigurationRouter }
Webserver configuration
type I18n ¶
type I18n struct { Provider string translation.Config }