Hi Everybody!
I’m working on porting some functionality from my company’s older web stack over to Caddy, but I’ve run into something that I’m having trouble accomplishing with standard plugin/middleware implementations.
I need to write a script tag out after the file content is served. I’m able to do this with other webserver implementations by either tacking it on after the request has been processed or by parsing the HTML file and injecting the script tag right before I write out the file contents. I can easily write this content out from a plugin, but I haven’t been able to figure out how to write it after, just before, the content is written. This makes it not play nice with the gzip plugin, since running my plugin before gzip results in a chunk of non-compressed javascript at the top and running after leads to an invalid request in the browser since I’ve appended bytes onto an already-compressed output.
So, is it possible to do this with caddy plugins? Am I missing something simple? Do I need to look into using a custom server type for this? Any help is appreciated! Thanks!