<!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.API.Capture</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-API-Capture.html");};
</script></head><body><divid="package-header"><ulclass="links"id="page-menu"><li><ahref="src/Servant-API-Capture.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.API.Capture</p></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"><spanclass="keyword">data</span><ahref="#t:Capture">Capture</a> sym a</li></ul></div><divid="interface"><h1>Documentation</h1><divclass="top"><pclass="src"><spanclass="keyword">data</span><aname="t:Capture"class="def">Capture</a> sym a <ahref="src/Servant-API-Capture.html#Capture"class="link">Source</a></p><divclass="doc"><p>Capture a value from the request path under a certain type <code>a</code>.</p><p>Example:</p><pre> -- GET /books/:isbn
type MyApi = "books" :> Capture "isbn" Text :> Get Book</pre></div><divclass="subs instances"><pid="control.i:Capture"class="caption collapser"onclick="toggleSection('i:Capture')">Instances</p><divid="section.i:Capture"class="show"><table><tr><tdclass="src">(<ahref="https://hackage.haskell.org/package/base-4.7.0.1/docs/GHC-TypeLits.html#t:KnownSymbol">KnownSymbol</a> capture, <ahref="Servant-Common-Text.html#t:FromText">FromText</a> a, <ahref="Servant-Server.html#t:HasServer">HasServer</a> sublayout) =><ahref="Servant-Server.html#t:HasServer">HasServer</a> (<ahref="Servant-API-Sub.html#t::-62-">(:>)</a> * (<ahref="Servant-API-Capture.html#t:Capture">Capture</a><ahref="https://hackage.haskell.org/package/base-4.7.0.1/docs/GHC-TypeLits.html#t:Symbol">Symbol</a> * capture a) sublayout)</td><tdclass="doc"><p>If you use <code><ahref="Servant-API-Capture.html#t:Capture">Capture</a></code> in one of the endpoints for your API,
this automatically requires your server-side handler to be a function
that takes an argument of the type specified by the <code><ahref="Servant-API-Capture.html#t:Capture">Capture</a></code>.
This lets servant worry about getting it from the URL and turning
it into a value of the type you specify.</p><p>You can control how it'll be converted from <code><ahref="https://hackage.haskell.org/package/text-1.2.0.0/docs/Data-Text.html#t:Text">Text</a></code> to your type
by simply providing an instance of <code><ahref="Servant-Common-Text.html#t:FromText">FromText</a></code> for your type.</p><p>Example:</p><pre>type MyApi = "books" :> Capture "isbn" Text :> Get Book
server :: Server MyApi
server = getBook
where getBook :: Text -> EitherT (Int, String) IO Book
getBook isbn = ...</pre></td></tr><tr><tdclass="src"><spanclass="keyword">type</span><ahref="Servant-Server.html#t:Server">Server</a> (<ahref="Servant-API-Sub.html#t::-62-">(:>)</a> * (<ahref="Servant-API-Capture.html#t:Capture">Capture</a><ahref="https://hackage.haskell.org/package/base-4.7.0.1/docs/GHC-TypeLits.html#t:Symbol">Symbol</a> * capture a) sublayout) = a -><ahref="Servant-Server.html#t:Server">Server</a> sublayout</td><tdclass="doc empty"> </td></tr></table></div></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>