First commit

This commit is contained in:
Miek Gieben
2016-03-18 20:57:35 +00:00
commit 3ec0d9fe6b
131 changed files with 15193 additions and 0 deletions

22
middleware/host.go Normal file
View File

@@ -0,0 +1,22 @@
package middleware
import (
"net"
"strings"
"github.com/miekg/dns"
)
// Host represents a host from the Caddyfile, may contain port.
type Host string
// Standard host will return the host portion of host, stripping
// of any port. The host will also be fully qualified and lowercased.
func (h Host) StandardHost() string {
// separate host and port
host, _, err := net.SplitHostPort(string(h))
if err != nil {
host, _, _ = net.SplitHostPort(string(h) + ":")
}
return strings.ToLower(dns.Fqdn(host))
}