Search code examples
haskellscotty

Serve static files from memory in Scotty webapp


For ease of app relocation I would like to serve static files from memory instead of disk in my Scotty application. I'm currently using wai-middleware-static to serve files from disk but I see that there is a wai-app-static that could do it, but it is not in the form of a Middleware.

Can I turn the wai-app-static Application into a Middleware or is there another package I am missing?


Solution

  • I could not find what I was looking for so I made my own: https://github.com/adamse/wai-middleware-static-embedded based on wai-middleware-static.

    It provides a function

    static :: [(FilePath, ByteString)] -> Middleware
    

    which serves a file if it is in the supplied list.