Documentation ¶
Overview ¶
Package origin implements tools and methods to compare and perform simple pattern-matching on the origin header of a request on the server-side, specifically in the context of cross-origin resource sharing (CORS).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
Get returns the value of the origin header in r.
An empty string is returned if the value in the header is "null", indicating an opaque origin.
func Match ¶
Match returns true if the scheme, hostname and port of origin match the ones in the given pattern.
Both the origin and the pattern must be formatted as:
scheme://hostname:port
Pattern may contain a wildcard "*" in any of the three components. For example, "https://*.example.com:*" will consider any subdomain of "example.com" on any port number as a match, provided that the scheme is HTTPS.
The port number may be omitted in either the origin or pattern when the scheme has a known standard port number. For example, "https://example.com" and "https://example.com:443" are a match.
The special pattern value "*" is equivalent to "*://*:*", and matches with any non-empty and valid origin.
func Split ¶
Split is similar to net.SplitHostPort, but accounts for the scheme (protocol), and returns the implicit corresponding port if origin doesn't explicitly mention one. For example, "https://example.com" will return "https", "example.com" and "443" as the port.