apmhttputil

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoteAddr

func RemoteAddr(req *http.Request, forwarded *ForwardedHeader) string

RemoteAddr returns the remote address for the HTTP request.

In order:

  • if the Forwarded header is set, then the first item in the list's "for" field is used, if it exists. The "for" value is returned even if it is an obfuscated identifier.
  • if the X-Real-Ip header is set, then its value is returned.
  • if the X-Forwarded-For header is set, then the first value in the comma-separated list is returned.
  • otherwise, the host portion of req.RemoteAddr is returned.

func RequestURL

func RequestURL(req *http.Request, forwarded *ForwardedHeader) model.URL

RequestURL returns a model.URL for req.

If req contains an absolute URI, the values will be split and sanitized, but no further processing performed. For all other requests (i.e. most server-side requests), we reconstruct the URL based on various proxy forwarding headers and other request attributes.

Types

type ForwardedHeader

type ForwardedHeader struct {
	For   string
	Host  string
	Proto string
}

ForwardedHeader holds information extracted from a "Forwarded" HTTP header.

func ParseForwarded

func ParseForwarded(f string) ForwardedHeader

ParseForwarded parses a "Forwarded" HTTP header.

Jump to

Keyboard shortcuts

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