<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>Servant.Utils.StaticFiles</title><linkhref="ocean.css"rel="stylesheet"type="text/css"title="Ocean"/><scriptsrc="haddock-util.js"type="text/javascript"></script><scripttype="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Servant-Utils-StaticFiles.html");};
</script></head><body><divid="package-header"><ulclass="links"id="page-menu"><li><ahref="src/Servant-Utils-StaticFiles.html">Source</a></li><li><ahref="index.html">Contents</a></li><li><ahref="doc-index.html">Index</a></li></ul><pclass="caption">servant-0.2: A family of combinators for defining webservices APIs and serving them</p></div><divid="content"><divid="module-header"><tableclass="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><pclass="caption">Servant.Utils.StaticFiles</p></div><divid="description"><pclass="caption">Description</p><divclass="doc"><p>This module defines a sever-side handler that lets you serve static files.</p><ul><li><code><ahref="Servant-Utils-StaticFiles.html#v:serveDirectory">serveDirectory</a></code> lets you serve anything that lives under a particular
directory on your filesystem.</li></ul></div></div><divid="synopsis"><pid="control.syn"class="caption expander"onclick="toggleSection('syn')">Synopsis</p><ulid="section.syn"class="hide"onclick="toggleSection('syn')"><liclass="src short"><ahref="#v:serveDirectory">serveDirectory</a> :: <ahref="https://hackage.haskell.org/package/base-4.7.0.1/docs/System-IO.html#t:FilePath">FilePath</a> -><ahref="Servant-Server.html#t:Server">Server</a><ahref="Servant-API-Raw.html#t:Raw">Raw</a></li></ul></div><divid="interface"><h1>Documentation</h1><divclass="top"><pclass="src"><aname="v:serveDirectory"class="def">serveDirectory</a> :: <ahref="https://hackage.haskell.org/package/base-4.7.0.1/docs/System-IO.html#t:FilePath">FilePath</a> -><ahref="Servant-Server.html#t:Server">Server</a><ahref="Servant-API-Raw.html#t:Raw">Raw</a><ahref="src/Servant-Utils-StaticFiles.html#serveDirectory"class="link">Source</a></p><divclass="doc"><p>Serve anything under the specified directory as a <code><ahref="Servant-API-Raw.html#t:Raw">Raw</a></code> endpoint.</p><pre>type MyApi = "static" :> Raw
server :: Server MyApi
server = serveDirectory "/var/www"
</pre><p>would capture any request to <code>/static/<something></code> and look for
<code><something></code> under <code>/var/www</code>.</p><p>It will do its best to guess the MIME type for that file, based on the extension,
and send an appropriate <em>Content-Type</em> header if possible.</p><p>If your goal is to serve HTML, CSS and Javascript files that use the rest of the API
as a webapp backend, you will most likely not want the static files to be hidden
behind a <em>/static/</em> prefix. In that case, remember to put the <code><ahref="Servant-Utils-StaticFiles.html#v:serveDirectory">serveDirectory</a></code>
handler in the last position, because <em>servant</em> will try to match the handlers
in order.</p></div></div></div></div><divid="footer"><p>Produced by <ahref="http://www.haskell.org/haddock/">Haddock</a> version 2.15.0</p></div></body></html>