httpserver: Implement {sever_port} placeholder (#2424)

This commit is contained in:
Max Heyer
2019-01-25 21:54:33 +01:00
committed by Toby Allen
parent a7aeb979be
commit 7f546e529e
2 changed files with 39 additions and 0 deletions
+10
View File
@@ -506,6 +506,16 @@ func (r *replacer) getSubstitution(key string) string {
return cert.NotBefore.Format("Jan 02 15:04:05 2006 MST")
}
return r.emptyValue
case "{server_port}":
_, port, err := net.SplitHostPort(r.request.Host)
if err != nil {
if r.request.TLS != nil {
return "443"
} else {
return "80"
}
}
return port
default:
// {labelN}
if strings.HasPrefix(key, "{label") {