webutil

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package webutil implements utility routines for web-related operations and applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalizeHost

func CanonicalizeHost(hostName, defaultDomain, defaultPort string) (protocol, fqhp, fqh, host, domain, port string, hosterr error)

CanonicalizeHost accepts a server host name as typically encountered by web server and generally obtained from the http request Host header field and canonicalizes it into: fqhp - fully qualified host+domain with a port - ie: host.domain:port fqh - fully qualified host+domain without a port - ie: host.domain host - the hostname, i.e. the first component of a . separated name domain - the second and subsequent components of a . separated name port - the port.

It is generally used for constructing redirects, determine/scoping cookie names etc.

The server name can be in any of the forms accepted by a web browser: 1. [<protocol>://]<ip-addr>[:port] 2. [<protocol>://]<name>[:<port>] 3. [<protocol>://]<name>[.<subdomain>]+[:<port>] The defaultDomain and defaultPort, if not "", will be used if there is no domain or port in hostName.

func StartBrowser

func StartBrowser(url string) bool

StartBrowser tries to open the URL in a browser and reports whether it succeeds.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL