Skip to content

Instantly share code, notes, and snippets.

@justinrolston
Created December 10, 2014 13:50
Show Gist options
  • Save justinrolston/d0aaeb0991d6b780da75 to your computer and use it in GitHub Desktop.
Save justinrolston/d0aaeb0991d6b780da75 to your computer and use it in GitHub Desktop.
working proxy
package main
import (
"fmt"
"log"
"net/http"
"github.com/elazarl/goproxy"
)
func main() {
proxy := goproxy.NewProxyHttpServer()
proxy.OnRequest().DoFunc(
func(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) {
nreq, _ := http.NewRequest("GET", "http://github.com", nil)
r.RequestURI = "http://github.com"
fmt.Println("------------")
fmt.Println(r.RequestURI)
return nreq, nil
})
log.Fatalln(http.ListenAndServe(":8080", proxy))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment