Files
fn-serverless/goproxy1.go
2012-12-30 19:21:31 -08:00

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))
}