github.com/coreos/goproxy@v0.0.0-20190513173959-f8dc2d7ba04e/examples/goproxy-upside-down-ternet/main.go (about) 1 package main 2 3 import ( 4 "github.com/elazarl/goproxy" 5 "github.com/elazarl/goproxy/ext/image" 6 "image" 7 "log" 8 "net/http" 9 ) 10 11 func main() { 12 proxy := goproxy.NewProxyHttpServer() 13 proxy.OnResponse().Do(goproxy_image.HandleImage(func(img image.Image, ctx *goproxy.ProxyCtx) image.Image { 14 dx, dy := img.Bounds().Dx(), img.Bounds().Dy() 15 16 nimg := image.NewRGBA(img.Bounds()) 17 for i := 0; i < dx; i++ { 18 for j := 0; j <= dy; j++ { 19 nimg.Set(i, j, img.At(i, dy-j-1)) 20 } 21 } 22 return nimg 23 })) 24 proxy.Verbose = true 25 log.Fatal(http.ListenAndServe(":8080", proxy)) 26 }