<!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.Alternative</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-Alternative.html");};
</script></head><body><divid="package-header"><ulclass="links"id="page-menu"><li><ahref="src/Servant-API-Alternative.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.Alternative</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> a <ahref="#t::-60--124--62-">:<|></a> b = a <ahref="#v::-60--124--62-">:<|></a> b</li></ul></div><divid="interface"><h1>Documentation</h1><divclass="top"><pclass="src"><spanclass="keyword">data</span> a <aname="t::-60--124--62-"class="def">:<|></a> b <spanclass="fixity">infixr 8</span><spanclass="rightedge"></span><ahref="src/Servant-API-Alternative.html#%3A%3C%7C%3E"class="link">Source</a></p><divclass="doc"><p>Union of two APIs, first takes precedence in case of overlap.</p><p>Example:</p><pre>type MyApi = "books" :> Get [Book] -- GET /books
:<|>"books" :> ReqBody Book :> Post Book -- POST /books</pre></div><divclass="subs constructors"><pclass="caption">Constructors</p><table><tr><tdclass="src">a <aname="v::-60--124--62-"class="def">:<|></a> b <spanclass="fixity">infixr 8</span><spanclass="rightedge"></span></td><tdclass="doc empty"> </td></tr></table></div><divclass="subs instances"><pid="control.i::-60--124--62-"class="caption collapser"onclick="toggleSection('i::-60--124--62-')">Instances</p><divid="section.i::-60--124--62-"class="show"><table><tr><tdclass="src">(<ahref="Servant-Server.html#t:HasServer">HasServer</a> a, <ahref="Servant-Server.html#t:HasServer">HasServer</a> b) =><ahref="Servant-Server.html#t:HasServer">HasServer</a> (<ahref="Servant-API-Alternative.html#t::-60--124--62-">(:<|>)</a> a b)</td><tdclass="doc"><p>A server for <code>a <code><ahref="Servant-API-Alternative.html#t::-60--124--62-">:<|></a></code> b</code> first tries to match the request again the route
represented by <code>a</code> and if it fails tries <code>b</code>. You must provide a request
handler for each route.</p><pre>type MyApi = "books" :> Get [Book] -- GET /books
:<|>"books" :> ReqBody Book :> Post Book -- POST /books
server :: Server MyApi
server = listAllBooks :<|> postBook
where listAllBooks = ...
postBook book = ...</pre></td></tr><tr><tdclass="src"><spanclass="keyword">type</span><ahref="Servant-Server.html#t:Server">Server</a> (<ahref="Servant-API-Alternative.html#t::-60--124--62-">(:<|>)</a> a b) = <ahref="Servant-API-Alternative.html#t::-60--124--62-">(:<|>)</a> (<ahref="Servant-Server.html#t:Server">Server</a> a) (<ahref="Servant-Server.html#t:Server">Server</a> b)</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>