Documentation
¶
Overview ¶
Package domain contains some nifty tools for manipulating domains and domain names.
Index ¶
- Constants
- func AddProtocol(url string) string
- func HasProtocol(url string) bool
- func Host(url string) string
- func Hostname(value string) string
- func IsLocalhost(hostname string) bool
- func IsValidHostname(hostname string) bool
- func NameOnly(value string) string
- func NotLocalhost(hostname string) bool
- func NotValidHostname(hostname string) bool
- func PathAndQuery(value string) string
- func Protocol(hostname string) string
- func TrimHostname(url string) string
- func TrueHostname(request *http.Request) string
Constants ¶
const ProtocolHTTP = "http://"
ProtocolHTTP is the HTTP protocol string
const ProtocolHTTPS = "https://"
ProtocolHTTPS is the HTTPS protocol string
Variables ¶
This section is empty.
Functions ¶
func AddProtocol ¶
AddProtocol adds a protocol to a URL if it does not already exist. Local domains use http:// and all other domains use https://
func HasProtocol ¶ added in v0.0.2
HasProtocol returns TRUE if the provided URL includes a protocol string
func Hostname ¶ added in v0.2.7
Hostname returns ONLY the hostname, removing the protocol, port, path, and querystring from a hostname
func IsLocalhost ¶
IsLocalhost returns TRUE if the hostname is a local domain
func IsValidHostname ¶ added in v0.2.0
func NameOnly ¶
NameOnly removes the protocol and port from a hostname deprecated: Use Hostname instead
func NotLocalhost ¶ added in v0.1.0
NotLocalhost returns TRUE if the hostname is NOT a local domain
func NotValidHostname ¶ added in v0.2.0
func PathAndQuery ¶ added in v0.2.12
PathAndQuery removes the protocol, hostname, and port from a URL, returning only the path and querystring.
func Protocol ¶
Protocol returns the protocol to use for a given hostname. Local domains return `http://`, while all other domains return `https://`
func TrimHostname ¶ added in v0.2.11
TrimHostname is an alias for PathAndQuery deprecated: Use PathAndQuery instead
func TrueHostname ¶ added in v0.2.10
TrueHostname returns the host name from the request, accounting for proxy headers (like X-Forwarded-Host).
Types ¶
This section is empty.