File: main.go

package info (click to toggle)
golang-github-sebest-xff 0.0~git20160910.6c115e0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports
  • size: 88 kB
  • sloc: makefile: 2
file content (24 lines) | stat: -rw-r--r-- 427 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package main

import (
	"net/http"

	"github.com/codegangsta/negroni"
	"github.com/gorilla/mux"
	"github.com/sebest/xff"
)

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

	mux := mux.NewRouter()
	mux.Handle("/", handler)

	n := negroni.Classic()
	xffmw, _ := xff.Default()
	n.Use(xffmw)
	n.UseHandler(mux)
	n.Run(":3000")
}