Documentation
¶
Index ¶
- type Config
- type ConfigSite
- type Server
- func (s *Server) DomainRouter(w http.ResponseWriter, r *http.Request)
- func (s *Server) RegisterMiddleware(cfg string, m middleware.Middleware)
- func (s *Server) RegisterSite(cfg string, site Site)
- func (s *Server) SetAuthentication(a auth.AuthenticationHandler)
- func (s *Server) Setup()
- func (s *Server) StartServer()
- func (s *Server) Stop(ctx context.Context)
- func (s *Server) Use(m ...gin.HandlerFunc)
- type Site
- type SiteConfig
- type TeardownSite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addr []string
TLSAddr []string
TLSconfig *tls.Config `toml:"-"`
Certfile string
Keyfile string
Sites map[string]SiteConfig
Middleware map[string]middleware.Config
}
Config that is used to map the toml config to the settings that are used.
type ConfigSite ¶
type ConfigSite interface {
Site
Defaults() SiteConfig
Setup(SiteConfig) error
}
ConfigSite is for sites that have to be configured
type Server ¶
type Server struct {
Conf *Config
NotFoundHandler http.Handler
// contains filtered or unexported fields
}
Server is an wrapper for the *http.Server and *gin.Engine
func CreateServer ¶
func CreateServer() *Server
CreateServer creates an server that can be run in a coroutine.
func (*Server) DomainRouter ¶
func (s *Server) DomainRouter(w http.ResponseWriter, r *http.Request)
DomainRouter redirects the requests to the routers of the domains
func (*Server) RegisterMiddleware ¶
func (s *Server) RegisterMiddleware(cfg string, m middleware.Middleware)
RegisterMiddleware registers middleware that has avanced functions, like persistence. That middleware allows configuration with the Setup Method and the Teardown allows an safe method for closing connections and shutting down. Middleware will be set up before sites.
func (*Server) RegisterSite ¶
RegisterSite adds an site to the engine as its own grouo it registers the defaults so that the application can load/dump it from/into an configfile or commandline options
func (*Server) SetAuthentication ¶
func (s *Server) SetAuthentication(a auth.AuthenticationHandler)
SetAuthentication sets the handler that is responsible for authentication
func (*Server) Setup ¶
func (s *Server) Setup()
Setup sets the server up. It loads the sites and prepare the server for startup. The Midleware and the site are setup in this Order: 1. Middleware.Setup 2. Site.Init 3. Middleware.Sites 4. Site.Setup
func (*Server) StartServer ¶
func (s *Server) StartServer()
StartServer starts the server as configured and sends the errormessage to the log. it blocks until all ports are closed.
func (*Server) Use ¶
func (s *Server) Use(m ...gin.HandlerFunc)
Use installs the middleware into the router. The Middleware must be able to detect multiple calls byy itself. Deduplication is not performed.
type Site ¶
type Site interface {
Init(*gin.RouterGroup)
}
Site is an Interface to abstract the modularized group of pages. The Middleware must be able to detect multiple calls by itself. Deduplication is not performed.
type SiteConfig ¶
type SiteConfig map[string]interface{}
SiteConfig is an interface for configitems of the site. The methods return the required items for the server
type TeardownSite ¶
type TeardownSite interface {
Site
Teardown()
}
TeardownSite is for sites that require to do steps before shutdown