helper

package
v0.0.0-...-8dcffa4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2019 License: Apache-2.0 Imports: 6 Imported by: 10

Documentation

Overview

Package helper should have the name commonUtilHelper but that was too long.

Index

Constants

View Source
const (
	ClientIP         = "Client-Ip"
	Forwarded        = "Forwarded"
	ForwardedFor     = "Forwarded-For"
	XClusterClientIP = "X-Cluster-Client-Ip"
	XForwarded       = "X-Forwarded"
	XForwardedFor    = "X-Forwarded-For"
	XRealIP          = "X-Real-Ip"
)

Available HTTP header keys for reading the real IP address.

Variables

ForwardedIPHeaders contains a list of available headers which might contain the client IP address.

Functions

func CommaListToSlice

func CommaListToSlice(str string) []string

CommaListToSlice transforms a comma separated string into a slice with trimmed spaces.

func RealIP

func RealIP(r *http.Request) string

RealIP extracts the remote address from a request and takes care of different headers in which an IP address can be stored. Checks if the IP in one of the header fields lies in net.PrivateIPRanges. Return value can be empty. A check for the RealIP costs 8 allocs, for now. This implementation trusts the values found in the forward headers.

func StringsToInts

func StringsToInts(ssl []string) []int

StringsToInts converts stringified integers into real ints. If an error occurs during converting the entries gets skipped.

Types

This section is empty.

Jump to

Keyboard shortcuts

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