move handler into its own package

This commit is contained in:
6543 2022-11-12 18:44:04 +01:00
parent 8519bba527
commit 7acb60874e
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE
5 changed files with 6 additions and 5 deletions

15
server/handler/hsts.go Normal file
View file

@ -0,0 +1,15 @@
package handler
import (
"strings"
)
// getHSTSHeader returns a HSTS header with includeSubdomains & preload for MainDomainSuffix and RawDomain, or an empty
// string for custom domains.
func getHSTSHeader(host, mainDomainSuffix, rawDomain string) string {
if strings.HasSuffix(host, mainDomainSuffix) || strings.EqualFold(host, rawDomain) {
return "max-age=63072000; includeSubdomains; preload"
} else {
return ""
}
}