mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
23 lines
482 B
Go
23 lines
482 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"github.com/elazarl/goproxy"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
verbose := flag.Bool("v", true, "should every proxy request be logged to stdout")
|
|
flag.Parse()
|
|
proxy := goproxy.NewProxyHttpServer()
|
|
proxy.Verbose = *verbose
|
|
proxy.OnRequest().DoFunc(
|
|
func(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
|
|
r.Header.Set("X-GoProxy", "yxorPoG-X")
|
|
return r, nil
|
|
})
|
|
|
|
log.Fatal(http.ListenAndServe(":8080", proxy))
|
|
}
|