fasthttp
fasthttp copied to clipboard
is there a way to change Response.Body() without memory copying?
i'm using minify https://github.com/tdewolff/minify to minify ctx.Response.Body() but trying to reduce GC pressure by doing arena but was wondering if i can just somehow modify the Response Body w/o mem copying... which will be better. is this possible?
mem := arena.NewArena()
o := arena.New[H](mem)
o.Data, o.Err = m.Bytes("text/html", ctx.Response.Body()) //minified here
if o.Err != nil {
log.Printf("minify1 %s", o.Err)
} else {
log.Printf("o.Data = %s", o.Data)
ctx.Response.SetBody(o.Data)
}
ctx.Response.Header.SetStatusCode(200)
ctx.Response.Header.SetContentType("text/html")
mem.Free()
Have you tried using Response.SetBodyRaw?