realip

package module
v0.0.0-...-f0c99a9 Latest Latest
Warning

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

Go to latest
Published: May 22, 2018 License: MIT Imports: 4 Imported by: 273

README

RealIP

GoDoc

Go package that can be used to get client's real public IP, which usually useful for logging HTTP server.

Feature
  • Follows the rule of X-Real-IP
  • Follows the rule of X-Forwarded-For
  • Exclude local or private address

Example

package main

import "github.com/tomasen/realip"

func (h *Handler) ServeIndexPage(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
	clientIP := realip.FromRequest(r)
	log.Println("GET / from", clientIP)
}

Developing

Commited code must pass:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromRequest

func FromRequest(r *http.Request) string

FromRequest return client's real public IP address from http request headers.

func RealIP

func RealIP(r *http.Request) string

RealIP is depreciated, use FromRequest instead

Types

This section is empty.

Jump to

Keyboard shortcuts

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