Ogeon/rustful

Add preimplemented file loader

Closed this issue · 0 comments

Ogeon commented

Loading and sending raw files, like images or CSS files, to the client is a very common thing to do, so I think it deserves to come prepackaged with Rustful in some way. I'm thinking either as a handler or a something that takes a path/file and a Response. It should at least support the most common file types and maybe allow extension for unimplemented types.

Mapping file extensions to MIME types would be necessary for this. Apache has a list of MIME types and extensions, so it could be possible to generate a map of some sort from that list using a build script.