utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RequestHeaderProtocol header for identifying the protocol (HTTP or HTTPS) that a client used to connect to your proxy or load balancer.
	RequestHeaderProtocol = "X-Forwarded-Proto"

	// RequestHeaderForwarded header for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or a load balancer.
	RequestHeaderForwarded = "X-Forwarded-For"
)

Functions

func RequestRawURL

func RequestRawURL(r *http.Request) string

RequestRawURL returns request original URL.

func RequestRemoteAddr

func RequestRemoteAddr(req *http.Request) string

RequestRemoteAddr finds the real remote address from request.

If the web server is behind an HTTP proxy or a load balancer, http.Request.RemoteAddr is IP of the proxy or load balancer. But most HTTP proxies and load balancers will attach a header to tell the web server request's real IP.

func RequestScheme

func RequestScheme(r *http.Request) string

RequestScheme try to parses request scheme.

If the web server is behind an HTTP proxy or a load balancer, it's hard to known if original request's scheme by http.Request.TLS property. Most HTTP proxies and load balancers will attach a header to tell upstream server the request's real scheme. So check if the header is set first.

Types

This section is empty.

Jump to

Keyboard shortcuts

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