2021-11-06 12:42:07 +00:00
|
|
|
package httpserver
|
|
|
|
|
|
|
|
import "github.com/gin-gonic/gin"
|
|
|
|
|
|
|
|
// 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 Site interface {
|
|
|
|
Init(*gin.RouterGroup)
|
2022-11-04 22:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ConfigSite is for sites that have to be configured
|
|
|
|
type ConfigSite interface {
|
|
|
|
Site
|
2022-11-05 07:44:37 +00:00
|
|
|
// Defaults returns the default values for the configuration
|
2021-11-06 12:42:07 +00:00
|
|
|
Defaults() SiteConfig
|
2022-11-05 07:44:37 +00:00
|
|
|
// Setup configures the Site with the read configuration.
|
|
|
|
// For the order how the methods are called refer to [Server.Setup]
|
2022-11-04 22:49:35 +00:00
|
|
|
Setup(SiteConfig) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// TeardownSite is for sites that require to do steps before shutdown
|
|
|
|
type TeardownSite interface {
|
2022-11-04 23:04:45 +00:00
|
|
|
Site
|
2022-11-05 07:44:37 +00:00
|
|
|
// Teardown is called before shutting down the server. Its for gracefully shutdowns of goroutines or longstanding connections
|
2022-11-04 22:49:35 +00:00
|
|
|
Teardown()
|
2021-11-06 12:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SiteConfig is an interface for configitems of the site. The methods return the required items for the server
|
2022-11-06 09:52:24 +00:00
|
|
|
type SiteConfig map[string]any
|