mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Initial commit.
This commit is contained in:
22
goproxy1.go
Normal file
22
goproxy1.go
Normal file
@@ -0,0 +1,22 @@
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user