Merge all the server components
This commit is contained in:
parent
85b5603d9d
commit
f5f2ac1a03
25 changed files with 365 additions and 352 deletions
|
|
@ -26,7 +26,7 @@ type Config struct {
|
|||
|
||||
// By default, the default domain redirects to the distillery repository.
|
||||
// If you want to change this, set an alternate domain name here.
|
||||
SelfRedirect *url.URL `env:"SELF_REDIRECT" default:"" parser:"https_url"`
|
||||
SelfRedirect *url.URL `env:"SELF_REDIRECT" default:"https://github.com/FAU-CDI/wisski-distillery" parser:"https_url"`
|
||||
|
||||
// By default, only the 'self' domain above is caught.
|
||||
// To catch additional domains, add them here (comma seperated)
|
||||
|
|
|
|||
|
|
@ -39,3 +39,19 @@ func (cfg Config) DefaultHost() string {
|
|||
func (cfg Config) DefaultSSLHost() string {
|
||||
return cfg.IfHttps(cfg.DefaultHost())
|
||||
}
|
||||
|
||||
// SlugFromHost returns the slug belonging to the appropriate host.
|
||||
func (cfg Config) SlugFromHost(host string) (slug string) {
|
||||
// extract an ':port' that happens to be in the host.
|
||||
domain, _, _ := strings.Cut(host, ":")
|
||||
|
||||
// check all the possible domain endings
|
||||
for _, suffix := range append([]string{cfg.DefaultDomain}, cfg.SelfExtraDomains...) {
|
||||
if strings.HasSuffix(domain, "."+suffix) {
|
||||
return domain[:len(domain)-len(suffix)-1]
|
||||
}
|
||||
}
|
||||
|
||||
// no domain found!
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue