rgrinberg / opium

Sinatra like web toolkit for OCaml
MIT License
755 stars 67 forks source link

Make a response helper for serving static files #72

Closed akxcv closed 4 years ago

akxcv commented 7 years ago

Currently, AFAIK, we can only serve static files in Opium by using the static middleware. If we want to, say, serve a specific file on a specific route (examples: GET / => index.html, response code 404 => 404.html), we have to write the code ourselves.

But I guess we could share the code from this file and use it as a helper.

Wouldn't it be nice?

rgrinberg commented 7 years ago

Yup, that would be a great change. We should investigate switching to https://github.com/inhabitedtype/ocaml-dispatch to do this easily though.

tmattio commented 4 years ago

@akxcv I believe this has been solved by #152. You can now use Opium_kernel.Static.serve and provide a read function to serve a file, either by reading the content from the local filesystem or from another source (e.g. Amazon S3).

I'm going to close this now, but don't hesitate to reopen if you have any questions.