Created
April 23, 2014 03:05
-
-
Save axgle/11201577 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/elazarl/goproxy" | |
"log" | |
"net/http" | |
) | |
func main() { | |
proxy := goproxy.NewProxyHttpServer() | |
proxy.OnRequest().DoFunc(func(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) { | |
req.Header.Set("user-agent", "GO!") | |
return req, nil | |
}) | |
proxy.Verbose = true | |
log.Fatal(http.ListenAndServe(":8888", proxy)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://httpbin.org/user-agent
for test