package
module
Version:
v0.0.0-...-f0c99a9
Opens a new window with list of versions in this module.
Published: May 22, 2018
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 323
Opens a new window with list of known importers.
README
¶
RealIP
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
¶
FromRequest return client's real public IP address from http request headers.
RealIP is depreciated, use FromRequest instead
Source Files
¶
Click to show internal directories.
Click to hide internal directories.