Back to godoc.org

Package webutil

v0.0.9
Latest Go to latest
Published: Jun 24, 2020 | License: Apache-2.0 | Module: github.com/grailbio/base

Overview

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

Index

Package Files

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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier