source

package
v0.9.56 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package source implements a custom predicate to match routes based on the source IP of a request.

It is similar in function and usage to the header predicate but has explicit support for IP adresses and netmasks to conveniently create routes based on a whole network of adresses, like a company network or something similar.

It is important to note, that this predicate should not be used as the only gatekeeper for secure endpoints. Always use proper authorization and authentication for access control!

To enable usage of this predicate behind loadbalancers or proxies, the X-Forwared-For header is used to determine the source of a request if it is available. If the X-Forwarded-For header is not present or does not contain a valid source address, the source IP of the incoming request is used for matching.

The source predicate supports one or more IP addresses with or without a netmask.

Examples:

// only match requests from 1.2.3.4
example1: Source("1.2.3.4") -> "http://example.org";

// only match requests from 1.2.3.0 - 1.2.3.255
example2: Source("1.2.3.0/24") -> "http://example.org";

// only match requests from 1.2.3.4 and the 2.2.2.0/24 network
example3: Source("1.2.3.4", "2.2.2.0/24") -> "http://example.org";

Index

Constants

View Source
const Name = "Source"

Variables

View Source
var InvalidArgsError = errors.New("invalid arguments")

Functions

func New

func New() routing.PredicateSpec

Types

This section is empty.

Jump to

Keyboard shortcuts

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