A Golang Middleware to handle X-Forwarded-For Header

Package xff is a net/http middleware/handler to parse Forwarded HTTP Extension in Golang.

Example usage

Install xff:

go get

Edit server.go:

package main

import (


func main() {
  handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("hello from " + r.RemoteAddr + "n"))

  xffmw, _ := xff.Default()
  http.ListenAndServe(":8080", xffmw.Handler(handler))

Then run your server:

go run server.go

The server now runs on localhost:8080:

$ curl -D - -H 'X-Forwarded-For:' http://localhost:8080/
HTTP/1.1 200 OK
Date: Fri, 20 Feb 2015 20:03:02 GMT
Content-Length: 29
Content-Type: text/plain; charset=utf-8

hello from


Uni Localization demo for Vue.js 3.x

A tiny and powerful enterprise-class solution for building tables,based on React and JSON