Documentation
¶
Overview ¶
Package httpserver provides developers with an HTTP-Server that route parts of the site on different domains and is configurable after the build
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 returns the default values for the configuration Defaults() SiteConfig // Setup configures the Site with the read configuration. // For the order how the methods are called refer to [Server.Setup] 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 ¶
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 is called before shutting down the server. Its for gracefully shutdowns of goroutines or longstanding connections Teardown() }
TeardownSite is for sites that require to do steps before shutdown
Directories
¶
Path | Synopsis |
---|---|
Package auth is for the abstraction of the authentication method.
|
Package auth is for the abstraction of the authentication method. |
command
module
|
|
Package constants provides static aliases when an value from an enum is required
|
Package constants provides static aliases when an value from an enum is required |
Package funcs provides fome functions that for special cases
|
Package funcs provides fome functions that for special cases |
Package menus provides an abstraction for providing an global menu that covers multiple sites
|
Package menus provides an abstraction for providing an global menu that covers multiple sites |
Package middleware provides some middleware
|
Package middleware provides some middleware |
db
Package db is an middleware that manages multiple database pools and provides applications with an way to access the database
|
Package db is an middleware that manages multiple database pools and provides applications with an way to access the database |
wellknown
Package wellknown provides an middleware that lets sites to register themselfs to wellknown uris
|
Package wellknown provides an middleware that lets sites to register themselfs to wellknown uris |
modules
|
|
saml
Package saml provides an Authentication Handler for authenticating over SAML
|
Package saml provides an Authentication Handler for authenticating over SAML |
Package templates helps sites to manage their templates
|
Package templates helps sites to manage their templates |