miniflux/vendor/github.com/tomasen/realip
2017-12-16 11:25:18 -08:00
..
.travis.yml Add FeedIcon API call and update dependencies 2017-12-16 11:25:18 -08:00
README.md Add FeedIcon API call and update dependencies 2017-12-16 11:25:18 -08:00
realip.go Add FeedIcon API call and update dependencies 2017-12-16 11:25:18 -08:00
realip_test.go Add FeedIcon API call and update dependencies 2017-12-16 11:25:18 -08:00

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: