jpillora / ipfilter

A package for IP Filtering in Go (golang)
MIT License
390 stars 47 forks source link

How allow/deny access by the host #5

Closed IgorN closed 4 years ago

IgorN commented 6 years ago

hi!

func handle(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Metrix") }

http.HandleFunc("/metrics", handle) - how can I allow this host(for example) for some ip's ?

Thanks!

jpillora commented 4 years ago
h := http.HandlerFunc(func handle(w http.ResponseWriter, r *http.Request) {
   fmt.Fprint(w, "Metrix")
})

h = ipfilter.Wrap(h, ipfilter.Options{  ...  })

http.HandleFunc("/metrics", h)

See https://godoc.org/github.com/jpillora/ipfilter#Wrap