These are chat archives for elazarl/goproxy

12th
Jun 2015
Alex Walker
@amlwwalker
Jun 12 2015 10:24
Have you got an example of flipping images using your library?
I have this, and it gets to printing out 'interceptor' but never makes it inside the function to actually do the flipping:
func FlipImages() net.Listener {
    listener, _ = net.Listen(CONN_TYPE, CONN_HOST+":"+CONN_PORT)
    proxy := goproxy.NewProxyHttpServer()
    interceptResponse := goproxy.HandlerFunc(func(ctx *goproxy.ProxyCtx) goproxy.Next {
        log.Println("URL: ", ctx.Resp.Request.URL)
        log.Println("interceptor")
        goproxy_image.HandleImage(func(img image.Image, ctx *goproxy.ProxyCtx) image.Image {
            dx, dy := img.Bounds().Dx(), img.Bounds().Dy()
            log.Println("image")
            nimg := image.NewRGBA(img.Bounds())
            for i := 0; i < dx; i++ {
                for j := 0; j <= dy; j++ {
                    nimg.Set(i, j, img.At(i, dy-j-1))
                }
            }
            return nimg
        })
        return goproxy.FORWARD
    })
    proxy.HandleResponse((interceptResponse))
    go http.Serve(listener, proxy) // you can probably ignore this error
    return listener
}