gotham-rs / gotham

A flexible web framework that promotes stability, safety, security and speed.

Home Page:https://gotham.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

file handle should support customized encoding type in http response head

efancier-cn opened this issue · comments

For single file web application, the common way to reduce the loading time is gzip the index.htm file and set the encoding field in response head, this also help embedded linux to reduce file system size - some of the cost sensitive embedded linux system use 32MB spi flash for bootloader, kernel and file system.

You could accomplish this with middleware or accessing/constructing the headers on the response directly -- it is just a Hyper response. You could then gzip the response body bytes with something like flate-2.

commented

Just for clarification - is this something you expect a middleware to do, or are you suggesting that to_file gets an option to do the gzip for you / only serve pre-gzip-ed files?