tdewolff / minify

Go minifiers for web formats
https://go.tacodewolff.nl/minify
MIT License
3.75k stars 220 forks source link

Support FastHTTP #590

Closed gaby closed 1 year ago

gaby commented 1 year ago

Currentl the Middleware() and MiddlewareWithError() functions only support net/http, would it be possible to add a separate one with support for FastHTTP?

tdewolff commented 1 year ago

Sure, what would be needed to support FastHTTP? Would you be able to create a PR for that?

gaby commented 1 year ago

@tdewolff I'm not sure, which is why I'm asking here. My guess is that it has something to do with doing a custom response write, but i'm not sure where to start.

gaby commented 1 year ago

I'm going to try some stuff, If i get it working I will post my solution here. I think it may work by getting the Response Body and passing that to m.Bytes("text/html", body)

gaby commented 1 year ago

As expected I was able to use the fasthttp.Response().Body() and pass it to minified, err := m.Bytes()

tdewolff commented 1 year ago

Great, thanks for sharing!