1
0
Fork 0
httpserver/site.go

30 Zeilen
999 B
Go

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)
}
// ConfigSite is for sites that have to be configured
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
}
// TeardownSite is for sites that require to do steps before shutdown
type TeardownSite interface {
Site
// Teardown is called before shutting down the server. Its for gracefully shutdowns of goroutines or longstanding connections
Teardown()
}
// SiteConfig is an interface for configitems of the site. The methods return the required items for the server
type SiteConfig map[string]interface{}