This file is indexed.

/usr/share/doc/libghc-servant-server-doc/html/Servant-Server.html is in libghc-servant-server-doc 0.8.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Servant.Server</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Servant-Server.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Servant-Server.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">servant-server-0.8.1: A family of combinators for defining webservices APIs and serving them</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">Servant.Server</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Run a wai application from an API</a></li><li><a href="#g:2">Construct a wai Application from an API</a></li><li><a href="#g:3">Handlers for all standard combinators</a></li><li><a href="#g:4">Debugging the server layout</a></li><li><a href="#g:5">Enter</a><ul><li><a href="#g:6">Basic functions and datatypes</a></li><li><a href="#g:7"><code>Nat</code> utilities</a></li><li><a href="#g:8">Functions based on mmorph</a></li></ul></li><li><a href="#g:9">Context</a><ul><li><a href="#g:10">NamedContext</a></li></ul></li><li><a href="#g:11">Basic Authentication</a></li><li><a href="#g:12">General Authentication</a></li><li><a href="#g:13">Default error type</a><ul><li><a href="#g:14">3XX</a></li><li><a href="#g:15">4XX</a></li><li><a href="#g:16">5XX</a></li></ul></li><li><a href="#g:17">Re-exports</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module lets you implement <code><a href="Servant-Server.html#t:Server">Server</a></code>s for defined APIs. You'll
 most likely just need <code><a href="Servant-Server.html#v:serve">serve</a></code>.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:serve">serve</a> :: <a href="Servant-Server.html#t:HasServer">HasServer</a> api '[] =&gt; <a href="Servant.html#t:Proxy">Proxy</a> api -&gt; <a href="Servant-Server.html#t:Server">Server</a> api -&gt; <a href="Servant-Server.html#t:Application">Application</a></li><li class="src short"><a href="#v:serveWithContext">serveWithContext</a> :: <a href="Servant-Server.html#t:HasServer">HasServer</a> api context =&gt; <a href="Servant.html#t:Proxy">Proxy</a> api -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server.html#t:Server">Server</a> api -&gt; <a href="Servant-Server.html#t:Application">Application</a></li><li class="src short"><a href="#v:toApplication">toApplication</a> :: <a href="Servant-Server-Internal-RoutingApplication.html#t:RoutingApplication">RoutingApplication</a> -&gt; <a href="Servant-Server.html#t:Application">Application</a></li><li class="src short"><span class="keyword">class</span> <a href="#t:HasServer">HasServer</a> api context <span class="keyword">where</span><ul class="subs"><li><span class="keyword">type</span> <a href="#t:ServerT">ServerT</a> api (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a></li></ul></li><li class="src short"><span class="keyword">type</span> <a href="#t:Server">Server</a> api = <a href="Servant-Server.html#t:ServerT">ServerT</a> api <a href="Servant-Server.html#t:Handler">Handler</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:Handler">Handler</a> = <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Except.html#t:ExceptT">ExceptT</a> <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a></li><li class="src short"><a href="#v:layout">layout</a> :: <a href="Servant-Server.html#t:HasServer">HasServer</a> api '[] =&gt; <a href="Servant.html#t:Proxy">Proxy</a> api -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></li><li class="src short"><a href="#v:layoutWithContext">layoutWithContext</a> :: <a href="Servant-Server.html#t:HasServer">HasServer</a> api context =&gt; <a href="Servant.html#t:Proxy">Proxy</a> api -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></li><li class="src short"><a href="#v:enter">enter</a> :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-Utils-Enter.html#t:Enter">Enter</a> typ arg ret =&gt; arg -&gt; typ -&gt; ret</li><li class="src short"><span class="keyword">newtype</span> m <a href="#t::-126--62-">:~&gt;</a> n :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) -&gt; (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> = <a href="#v:Nat">Nat</a> {<ul class="subs"><li><a href="#v:unNat">unNat</a> :: <span class="keyword">forall</span> a. m a -&gt; n a</li></ul>}</li><li class="src short"><a href="#v:liftNat">liftNat</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#t:MonadTrans">MonadTrans</a> t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m) =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> m (t m)</li><li class="src short"><a href="#v:runReaderTNat">runReaderTNat</a> :: r -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m) m</li><li class="src short"><a href="#v:evalStateTLNat">evalStateTLNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; s -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m) m</li><li class="src short"><a href="#v:evalStateTSNat">evalStateTSNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; s -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Strict.html#t:StateT">StateT</a> s m) m</li><li class="src short"><a href="#v:logWriterTLNat">logWriterTLNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> m =&gt; (w -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> ()) -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m) m</li><li class="src short"><a href="#v:logWriterTSNat">logWriterTSNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> m =&gt; (w -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> ()) -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m) m</li><li class="src short"><a href="#v:hoistNat">hoistNat</a> :: (MFunctor t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m) =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> m n -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (t m) (t n)</li><li class="src short"><a href="#v:embedNat">embedNat</a> :: (MMonad t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> n) =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> m (t n) -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (t m) (t n)</li><li class="src short"><a href="#v:squashNat">squashNat</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m, MMonad t) =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (t (t m)) (t m)</li><li class="src short"><a href="#v:generalizeNat">generalizeNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Applicative.html#t:Applicative">Applicative</a> m =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Identity.html#t:Identity">Identity</a> m</li><li class="src short"><a href="#v:tweakResponse">tweakResponse</a> :: (<a href="Servant-Server-Internal-RoutingApplication.html#t:RouteResult">RouteResult</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Response">Response</a> -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:RouteResult">RouteResult</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Response">Response</a>) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env</li><li class="src short"><span class="keyword">data</span> <a href="#t:Context">Context</a> contextTypes <span class="keyword">where</span><ul class="subs"><li><a href="#v:EmptyContext">EmptyContext</a> :: <a href="Servant-Server.html#t:Context">Context</a> '[]</li><li><a href="#v::.">(:.)</a> :: x -&gt; <a href="Servant-Server.html#t:Context">Context</a> xs -&gt; <a href="Servant-Server.html#t:Context">Context</a> (x ': xs)</li></ul></li><li class="src short"><span class="keyword">class</span> <a href="#t:HasContextEntry">HasContextEntry</a> context val <span class="keyword">where</span><ul class="subs"></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:NamedContext">NamedContext</a> name subContext = <a href="#v:NamedContext">NamedContext</a> (<a href="Servant-Server.html#t:Context">Context</a> subContext)</li><li class="src short"><a href="#v:descendIntoNamedContext">descendIntoNamedContext</a> :: <span class="keyword">forall</span> context name subContext. <a href="Servant-Server.html#t:HasContextEntry">HasContextEntry</a> context (<a href="Servant-Server.html#t:NamedContext">NamedContext</a> name subContext) =&gt; <a href="Servant.html#t:Proxy">Proxy</a> (name :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:Symbol">Symbol</a>) -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server.html#t:Context">Context</a> subContext</li><li class="src short"><span class="keyword">newtype</span> <a href="#t:BasicAuthCheck">BasicAuthCheck</a> usr = <a href="#v:BasicAuthCheck">BasicAuthCheck</a> {<ul class="subs"><li><a href="#v:unBasicAuthCheck">unBasicAuthCheck</a> :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-BasicAuth.html#t:BasicAuthData">BasicAuthData</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr)</li></ul>}</li><li class="src short"><span class="keyword">data</span> <a href="#t:BasicAuthResult">BasicAuthResult</a> usr<ul class="subs"><li>= <a href="#v:Unauthorized">Unauthorized</a></li><li>| <a href="#v:BadPassword">BadPassword</a></li><li>| <a href="#v:NoSuchUser">NoSuchUser</a></li><li>| <a href="#v:Authorized">Authorized</a> usr</li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:ServantErr">ServantErr</a> = <a href="#v:ServantErr">ServantErr</a> {<ul class="subs"><li><a href="#v:errHTTPCode">errHTTPCode</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a></li><li><a href="#v:errReasonPhrase">errReasonPhrase</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a></li><li><a href="#v:errBody">errBody</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></li><li><a href="#v:errHeaders">errHeaders</a> :: [<a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Header.html#t:Header">Header</a>]</li></ul>}</li><li class="src short"><a href="#v:err300">err300</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err301">err301</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err302">err302</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err303">err303</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err304">err304</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err305">err305</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err307">err307</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err400">err400</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err401">err401</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err402">err402</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err403">err403</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err404">err404</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err405">err405</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err406">err406</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err407">err407</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err409">err409</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err410">err410</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err411">err411</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err412">err412</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err413">err413</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err414">err414</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err415">err415</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err416">err416</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err417">err417</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err500">err500</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err501">err501</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err502">err502</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err503">err503</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err504">err504</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><a href="#v:err505">err505</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:Application">Application</a> = <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Request">Request</a> -&gt; (<a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Response">Response</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:ResponseReceived">ResponseReceived</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:ResponseReceived">ResponseReceived</a></li></ul></div><div id="interface"><h1 id="g:1">Run a wai application from an API</h1><div class="top"><p class="src"><a id="v:serve" class="def">serve</a> :: <a href="Servant-Server.html#t:HasServer">HasServer</a> api '[] =&gt; <a href="Servant.html#t:Proxy">Proxy</a> api -&gt; <a href="Servant-Server.html#t:Server">Server</a> api -&gt; <a href="Servant-Server.html#t:Application">Application</a> <a href="src/Servant-Server.html#serve" class="link">Source</a> <a href="#v:serve" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:serve">serve</a></code> allows you to implement an API and produce a wai <code><a href="Servant-Server.html#t:Application">Application</a></code>.</p><p>Example:</p><pre>type MyApi = &quot;books&quot; :&gt; Get '[JSON] [Book] -- GET /books
        :&lt;|&gt; &quot;books&quot; :&gt; ReqBody Book :&gt; Post '[JSON] Book -- POST /books

server :: Server MyApi
server = listAllBooks :&lt;|&gt; postBook
  where listAllBooks = ...
        postBook book = ...

myApi :: Proxy MyApi
myApi = Proxy

app :: Application
app = serve myApi server

main :: IO ()
main = Network.Wai.Handler.Warp.run 8080 app</pre></div></div><div class="top"><p class="src"><a id="v:serveWithContext" class="def">serveWithContext</a> :: <a href="Servant-Server.html#t:HasServer">HasServer</a> api context =&gt; <a href="Servant.html#t:Proxy">Proxy</a> api -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server.html#t:Server">Server</a> api -&gt; <a href="Servant-Server.html#t:Application">Application</a> <a href="src/Servant-Server.html#serveWithContext" class="link">Source</a> <a href="#v:serveWithContext" class="selflink">#</a></p></div><h1 id="g:2">Construct a wai Application from an API</h1><div class="top"><p class="src"><a id="v:toApplication" class="def">toApplication</a> :: <a href="Servant-Server-Internal-RoutingApplication.html#t:RoutingApplication">RoutingApplication</a> -&gt; <a href="Servant-Server.html#t:Application">Application</a> <a href="src/Servant-Server-Internal-RoutingApplication.html#toApplication" class="link">Source</a> <a href="#v:toApplication" class="selflink">#</a></p></div><h1 id="g:3">Handlers for all standard combinators</h1><div class="top"><p class="src"><span class="keyword">class</span> <a id="t:HasServer" class="def">HasServer</a> api context <span class="keyword">where</span> <a href="src/Servant-Server-Internal.html#HasServer" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></p><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="Servant-Server.html#v:route">route</a></p></div><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a id="t:ServerT" class="def">ServerT</a> api (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a id="v:route" class="def">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> api -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> api) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div><div class="subs instances"><p id="control.i:HasServer" class="caption collapser" onclick="toggleSection('i:HasServer')">Instances</p><div id="section.i:HasServer" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:1" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:1')"></span> <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Raw.html#t:Raw">Raw</a> context</span> <a href="src/Servant-Server-Internal.html#line-398" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>Just pass the request to the underlying application and serve its response.</p><p>Example:</p><pre>type MyApi = &quot;images&quot; :&gt; Raw

server :: Server MyApi
server = serveDirectory &quot;/var/www/images&quot;</pre></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:1" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Raw.html#t:Raw">Raw</a> (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Raw.html#t:Raw">Raw</a>) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Raw.html#t:Raw">Raw</a> context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Raw.html#t:Raw">Raw</a> context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:2" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:2')"></span> (<a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> a context, <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> b context) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Alternative.html#t::-60--124--62-">(:&lt;|&gt;)</a> a b) context</span> <a href="src/Servant-Server-Internal.html#line-97" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>A server for <code>a <code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Alternative.html#t::-60--124--62-">:&lt;|&gt;</a></code> b</code> first tries to match the request against 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 = &quot;books&quot; :&gt; Get '[JSON] [Book] -- GET /books
        :&lt;|&gt; &quot;books&quot; :&gt; ReqBody Book :&gt; Post '[JSON] Book -- POST /books

server :: Server MyApi
server = listAllBooks :&lt;|&gt; postBook
  where listAllBooks = ...
        postBook book = ...</pre></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:2" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Alternative.html#t::-60--124--62-">(:&lt;|&gt;)</a> a b) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Alternative.html#t::-60--124--62-">(:&lt;|&gt;)</a> a b) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> (a <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Alternative.html#t::-60--124--62-">:&lt;|&gt;</a> b) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> (a <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Alternative.html#t::-60--124--62-">:&lt;|&gt;</a> b) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:3" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:3')"></span> (<a href="Servant-Server.html#t:HasContextEntry">HasContextEntry</a> context (<a href="Servant-Server.html#t:NamedContext">NamedContext</a> name subContext), <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> subApi subContext) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-WithNamedContext.html#t:WithNamedContext">WithNamedContext</a> name subContext subApi) context</span> <a href="src/Servant-Server-Internal.html#line-517" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:3" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-WithNamedContext.html#t:WithNamedContext">WithNamedContext</a> name subContext subApi) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-WithNamedContext.html#t:WithNamedContext">WithNamedContext</a> name subContext subApi) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-WithNamedContext.html#t:WithNamedContext">WithNamedContext</a> name subContext subApi) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-WithNamedContext.html#t:WithNamedContext">WithNamedContext</a> name subContext subApi) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:4" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:4')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownSymbol">KnownSymbol</a> realm, <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context, <a href="Servant-Server.html#t:HasContextEntry">HasContextEntry</a> context (<a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> usr)) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-BasicAuth.html#t:BasicAuth">BasicAuth</a> realm usr) api) context</span> <a href="src/Servant-Server-Internal.html#line-492" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>Basic Authentication</p></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:4" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-BasicAuth.html#t:BasicAuth">BasicAuth</a> realm usr) api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-BasicAuth.html#t:BasicAuth">BasicAuth</a> realm usr) api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-BasicAuth.html#t:BasicAuth">BasicAuth</a> realm usr) api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-BasicAuth.html#t:BasicAuth">BasicAuth</a> realm usr) api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:5" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:5')"></span> <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Version.html#t:HttpVersion">HttpVersion</a> api) context</span> <a href="src/Servant-Server-Internal.html#line-485" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:5" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Version.html#t:HttpVersion">HttpVersion</a> api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Version.html#t:HttpVersion">HttpVersion</a> api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Version.html#t:HttpVersion">HttpVersion</a> api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Version.html#t:HttpVersion">HttpVersion</a> api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:6" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:6')"></span> <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Vault.html#t:Vault">Vault</a> api) context</span> <a href="src/Servant-Server-Internal.html#line-479" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:6" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Vault.html#t:Vault">Vault</a> api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Vault.html#t:Vault">Vault</a> api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Vault.html#t:Vault">Vault</a> api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Vault.html#t:Vault">Vault</a> api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:7" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:7')"></span> <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-IsSecure.html#t:IsSecure">IsSecure</a> api) context</span> <a href="src/Servant-Server-Internal.html#line-471" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:7" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-IsSecure.html#t:IsSecure">IsSecure</a> api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-IsSecure.html#t:IsSecure">IsSecure</a> api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-IsSecure.html#t:IsSecure">IsSecure</a> api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-IsSecure.html#t:IsSecure">IsSecure</a> api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:8" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:8')"></span> <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-RemoteHost.html#t:RemoteHost">RemoteHost</a> api) context</span> <a href="src/Servant-Server-Internal.html#line-465" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:8" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-RemoteHost.html#t:RemoteHost">RemoteHost</a> api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-RemoteHost.html#t:RemoteHost">RemoteHost</a> api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-RemoteHost.html#t:RemoteHost">RemoteHost</a> api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-RemoteHost.html#t:RemoteHost">RemoteHost</a> api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:9" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:9')"></span> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ContentTypes.html#t:AllCTUnrender">AllCTUnrender</a> list a, <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ReqBody.html#t:ReqBody">ReqBody</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> list a) api) context</span> <a href="src/Servant-Server-Internal.html#line-430" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>If you use <code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ReqBody.html#t:ReqBody">ReqBody</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 <code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ReqBody.html#t:ReqBody">ReqBody</a></code>.
 The <code>Content-Type</code> header is inspected, and the list provided is used to
 attempt deserialization. If the request does not have a <code>Content-Type</code>
 header, it is treated as <code>application/octet-stream</code> (as specified in
 <a href="http://tools.ietf.org/html/rfc7231#section-3.1.1.5">RFC7231</a>.
 This lets servant worry about extracting it from the request and turning
 it into a value of the type you specify.</p><p>All it asks is for a <code>FromJSON</code> instance.</p><p>Example:</p><pre>type MyApi = &quot;books&quot; :&gt; ReqBody '[JSON] Book :&gt; Post '[JSON] Book

server :: Server MyApi
server = postBook
  where postBook :: Book -&gt; Handler Book
        postBook book = ...insert into your db...</pre></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:9" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ReqBody.html#t:ReqBody">ReqBody</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> list a) api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ReqBody.html#t:ReqBody">ReqBody</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> list a) api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ReqBody.html#t:ReqBody">ReqBody</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> list a) api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ReqBody.html#t:ReqBody">ReqBody</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> list a) api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:10" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:10')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownSymbol">KnownSymbol</a> sym, <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryFlag">QueryFlag</a> sym) api) context</span> <a href="src/Servant-Server-Internal.html#line-373" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>If you use <code><code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryFlag">QueryFlag</a></code> &quot;published&quot;</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 type <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a></code>.</p><p>Example:</p><pre>type MyApi = &quot;books&quot; :&gt; QueryFlag &quot;published&quot; :&gt; Get '[JSON] [Book]

server :: Server MyApi
server = getBooks
  where getBooks :: Bool -&gt; Handler [Book]
        getBooks onlyPublished = ...return all books, or only the ones that are already published, depending on the argument...</pre></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:10" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryFlag">QueryFlag</a> sym) api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryFlag">QueryFlag</a> sym) api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryFlag">QueryFlag</a> sym) api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryFlag">QueryFlag</a> sym) api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:11" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:11')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownSymbol">KnownSymbol</a> sym, <a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a> a, <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParams">QueryParams</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) context</span> <a href="src/Servant-Server-Internal.html#line-342" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>If you use <code><code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParams">QueryParams</a></code> &quot;authors&quot; Text</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 type <code>[<code>Text</code>]</code>.</p><p>This lets servant worry about looking up 0 or more values in the query string
 associated to <code>authors</code> and turning each of them into a value of
 the type you specify.</p><p>You can control how the individual values are converted from <code>Text</code> to your type
 by simply providing an instance of <code><a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a></code> for your type.</p><p>Example:</p><pre>type MyApi = &quot;books&quot; :&gt; QueryParams &quot;authors&quot; Text :&gt; Get '[JSON] [Book]

server :: Server MyApi
server = getBooksBy
  where getBooksBy :: [Text] -&gt; Handler [Book]
        getBooksBy authors = ...return all books by these authors...</pre></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:11" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParams">QueryParams</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParams">QueryParams</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParams">QueryParams</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParams">QueryParams</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:12" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:12')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownSymbol">KnownSymbol</a> sym, <a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a> a, <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParam">QueryParam</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) context</span> <a href="src/Servant-Server-Internal.html#line-306" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>If you use <code><code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParam">QueryParam</a></code> &quot;author&quot; Text</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 type <code><code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Maybe.html#t:Maybe">Maybe</a></code> <code>Text</code></code>.</p><p>This lets servant worry about looking it up in the query string
 and turning it into a value of the type you specify, enclosed
 in <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Maybe.html#t:Maybe">Maybe</a></code>, because it may not be there and servant would then
 hand you <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Maybe.html#v:Nothing">Nothing</a></code>.</p><p>You can control how it'll be converted from <code>Text</code> to your type
 by simply providing an instance of <code><a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a></code> for your type.</p><p>Example:</p><pre>type MyApi = &quot;books&quot; :&gt; QueryParam &quot;author&quot; Text :&gt; Get '[JSON] [Book]

server :: Server MyApi
server = getBooksBy
  where getBooksBy :: Maybe Text -&gt; Handler [Book]
        getBooksBy Nothing       = ...return all books...
        getBooksBy (Just author) = ...return books by the given author...</pre></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:12" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParam">QueryParam</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParam">QueryParam</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParam">QueryParam</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-QueryParam.html#t:QueryParam">QueryParam</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> sym a) api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:13" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:13')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownSymbol">KnownSymbol</a> sym, <a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a> a, <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Header.html#t:Header">Header</a> sym a) api) context</span> <a href="src/Servant-Server-Internal.html#line-274" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>If you use <code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Header.html#t:Header">Header</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 <code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Header.html#t:Header">Header</a></code>.
 This lets servant worry about extracting it from the request and turning
 it into a value of the type you specify.</p><p>All it asks is for a <code><a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a></code> instance.</p><p>Example:</p><pre>newtype Referer = Referer Text
  deriving (Eq, Show, FromHttpApiData)

           -- GET /view-my-referer
type MyApi = &quot;view-my-referer&quot; :&gt; Header &quot;Referer&quot; Referer :&gt; Get '[JSON] Referer

server :: Server MyApi
server = viewReferer
  where viewReferer :: Referer -&gt; Handler referer
        viewReferer referer = return referer</pre></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:13" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Header.html#t:Header">Header</a> sym a) api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Header.html#t:Header">Header</a> sym a) api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Header.html#t:Header">Header</a> sym a) api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Header.html#t:Header">Header</a> sym a) api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:14" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:14')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownSymbol">KnownSymbol</a> capture, <a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a> a, <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 sublayout context) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:CaptureAll">CaptureAll</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) sublayout) context</span> <a href="src/Servant-Server-Internal.html#line-155" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>If you use <code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:CaptureAll">CaptureAll</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 a list of the type specified by
 the <code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:CaptureAll">CaptureAll</a></code>. This lets servant worry about getting values from
 the URL and turning them into values of the type you specify.</p><p>You can control how they'll be converted from <code>Text</code> to your type
 by simply providing an instance of <code><a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a></code> for your type.</p><p>Example:</p><pre>type MyApi = &quot;src&quot; :&gt; CaptureAll &quot;segments&quot; Text :&gt; Get '[JSON] SourceFile

server :: Server MyApi
server = getSourceFile
  where getSourceFile :: [Text] -&gt; Handler Book
        getSourceFile pathSegments = ...</pre></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:14" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:CaptureAll">CaptureAll</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) sublayout) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:CaptureAll">CaptureAll</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) sublayout) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:CaptureAll">CaptureAll</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) sublayout) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:CaptureAll">CaptureAll</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) sublayout) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:15" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:15')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownSymbol">KnownSymbol</a> capture, <a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a> a, <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:Capture">Capture</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) api) context</span> <a href="src/Servant-Server-Internal.html#line-123" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>If you use <code><a href="file:///usr/share/doc/libghc-servant-doc/html/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><a href="file:///usr/share/doc/libghc-servant-doc/html/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>Text</code> to your type
 by simply providing an instance of <code><a href="file:///usr/share/doc/libghc-http-api-data-doc/html/Web-HttpApiData-Internal.html#t:FromHttpApiData">FromHttpApiData</a></code> for your type.</p><p>Example:</p><pre>type MyApi = &quot;books&quot; :&gt; Capture &quot;isbn&quot; Text :&gt; Get '[JSON] Book

server :: Server MyApi
server = getBook
  where getBook :: Text -&gt; Handler Book
        getBook isbn = ...</pre></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:15" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:Capture">Capture</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> k1 (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:Capture">Capture</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:Capture">Capture</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Capture.html#t:Capture">Capture</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> capture a) api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:16" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:16')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownSymbol">KnownSymbol</a> path, <a href="Servant-Server.html#t:HasServer">HasServer</a> k1 api context) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:Symbol">Symbol</a> k1 path api) context</span> <a href="src/Servant-Server-Internal.html#line-455" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc"><p>Make sure the incoming request starts with <code>&quot;/path&quot;</code>, strip it and
 pass the rest of the request path to <code>api</code>.</p></td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:16" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:Symbol">Symbol</a> k1 path api) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">(:&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:Symbol">Symbol</a> k1 path api) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:Symbol">Symbol</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) path api) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:Symbol">Symbol</a> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Sub.html#t::-62-">:&gt;</a> k1) path api) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:17" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:17')"></span> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ContentTypes.html#t:AllCTRender">AllCTRender</a> ctypes a, <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:ReflectMethod">ReflectMethod</a> k1 method, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownNat">KnownNat</a> status, <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ResponseHeaders.html#t:GetHeaders">GetHeaders</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ResponseHeaders.html#t:Headers">Headers</a> h a)) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ResponseHeaders.html#t:Headers">Headers</a> h a)) context</span> <a href="src/Servant-Server-Internal.html#line-244" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:17" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ResponseHeaders.html#t:Headers">Headers</a> h a)) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ResponseHeaders.html#t:Headers">Headers</a> h a)) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ResponseHeaders.html#t:Headers">Headers</a> h a)) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ResponseHeaders.html#t:Headers">Headers</a> h a)) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasServer:HasServer:18" class="instance expander" onclick="toggleSection('i:ic:HasServer:HasServer:18')"></span> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-ContentTypes.html#t:AllCTRender">AllCTRender</a> ctypes a, <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:ReflectMethod">ReflectMethod</a> k1 method, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:KnownNat">KnownNat</a> status) =&gt; <a href="Servant-Server.html#t:HasServer">HasServer</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes a) context</span> <a href="src/Servant-Server-Internal.html#line-234" class="link">Source</a> <a href="#t:HasServer" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:HasServer:HasServer:18" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="Servant-Server.html#t:ServerT">ServerT</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes a) (context :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes a) (m :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="src/Servant-Server-Internal.html#ServerT" class="link">Source</a> <a href="#t:ServerT" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:route">route</a> :: <a href="Servant.html#t:Proxy">Proxy</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes a) context -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:Delayed">Delayed</a> env (<a href="Servant-Server.html#t:Server">Server</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-Verbs.html#t:Verb">Verb</a> k1 <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> method status ctypes a) context) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal.html#route" class="link">Source</a> <a href="#v:route" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Server" class="def">Server</a> api = <a href="Servant-Server.html#t:ServerT">ServerT</a> api <a href="Servant-Server.html#t:Handler">Handler</a> <a href="src/Servant-Server-Internal.html#Server" class="link">Source</a> <a href="#t:Server" class="selflink">#</a></p></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Handler" class="def">Handler</a> = <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Except.html#t:ExceptT">ExceptT</a> <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> <a href="src/Servant-Server-Internal-ServantErr.html#Handler" class="link">Source</a> <a href="#t:Handler" class="selflink">#</a></p></div><h1 id="g:4">Debugging the server layout</h1><div class="top"><p class="src"><a id="v:layout" class="def">layout</a> :: <a href="Servant-Server.html#t:HasServer">HasServer</a> api '[] =&gt; <a href="Servant.html#t:Proxy">Proxy</a> api -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> <a href="src/Servant-Server.html#layout" class="link">Source</a> <a href="#v:layout" class="selflink">#</a></p><div class="doc"><p>The function <code><a href="Servant-Server.html#v:layout">layout</a></code> produces a textual description of the internal
 router layout for debugging purposes. Note that the router layout is
 determined just by the API, not by the handlers.</p><p>Example:</p><p>For the following API</p><pre>type API =
       &quot;a&quot; :&gt; &quot;d&quot; :&gt; Get '[JSON] NoContent
  :&lt;|&gt; &quot;b&quot; :&gt; Capture &quot;x&quot; Int :&gt; Get '[JSON] Bool
  :&lt;|&gt; &quot;c&quot; :&gt; Put '[JSON] Bool
  :&lt;|&gt; &quot;a&quot; :&gt; &quot;e&quot; :&gt; Get '[JSON] Int
  :&lt;|&gt; &quot;b&quot; :&gt; Capture &quot;x&quot; Int :&gt; Put '[JSON] Bool
  :&lt;|&gt; Raw</pre><p>we get the following output:</p><pre>/
&#9500;&#9472; a/
&#9474;  &#9500;&#9472; d/
&#9474;  &#9474;  &#9492;&#9472;&#8226;
&#9474;  &#9492;&#9472; e/
&#9474;     &#9492;&#9472;&#8226;
&#9500;&#9472; b/
&#9474;  &#9492;&#9472; &lt;capture&gt;/
&#9474;     &#9500;&#9472;&#8226;
&#9474;     &#9478;
&#9474;     &#9492;&#9472;&#8226;
&#9500;&#9472; c/
&#9474;  &#9492;&#9472;&#8226;
&#9478;
&#9492;&#9472; &lt;raw&gt;</pre><p>Explanation of symbols:</p><dl><dt><code>&#9500;</code></dt><dd>Normal lines reflect static branching via a table.</dd><dt><code>a/</code></dt><dd>Nodes reflect static path components.</dd><dt><code>&#9472;&#8226;</code></dt><dd>Leaves reflect endpoints.</dd><dt><code>&lt;capture&gt;/</code></dt><dd>This is a delayed capture of a path component.</dd><dt><code>&lt;raw&gt;</code></dt><dd>This is a part of the API we do not know anything about.</dd><dt><code>&#9478;</code></dt><dd>Dashed lines suggest a dynamic choice between the part above
 and below. If there is a success for fatal failure in the first part,
 that one takes precedence. If both parts fail, the &quot;better&quot; error
 code will be returned.</dd></dl></div></div><div class="top"><p class="src"><a id="v:layoutWithContext" class="def">layoutWithContext</a> :: <a href="Servant-Server.html#t:HasServer">HasServer</a> api context =&gt; <a href="Servant.html#t:Proxy">Proxy</a> api -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> <a href="src/Servant-Server.html#layoutWithContext" class="link">Source</a> <a href="#v:layoutWithContext" class="selflink">#</a></p><div class="doc"><p>Variant of <code><a href="Servant-Server.html#v:layout">layout</a></code> that takes an additional <code><a href="Servant-Server.html#t:Context">Context</a></code>.</p></div></div><h1 id="g:5">Enter</h1><div class="doc"><p>Sometimes our cherished <code>ExceptT</code> monad isn't quite the type you'd like for
 your handlers. Maybe you want to thread some configuration in a <code>Reader</code>
 monad. Or have your types ensure that your handlers don't do any IO. Enter
 <code><a href="Servant-Server.html#v:enter">enter</a></code>.</p><p>With <code><a href="Servant-Server.html#v:enter">enter</a></code>, you can provide a function, wrapped in the `(:~&gt;)` / <code><a href="Servant-Server.html#v:Nat">Nat</a></code>
 newtype, to convert any number of endpoints from one type constructor to
 another. For example</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>import Control.Monad.Reader
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>import qualified Control.Category as C
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>type ReaderAPI = &quot;ep1&quot; :&gt; Get '[JSON] Int :&lt;|&gt; &quot;ep2&quot; :&gt; Get '[JSON] String
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let readerServer = return 1797 :&lt;|&gt; ask :: ServerT ReaderAPI (Reader String)
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let mainServer = enter (generalizeNat C.. (runReaderTNat &quot;hi&quot;)) readerServer :: Server ReaderAPI
</code></strong></pre></div><h2 id="g:6">Basic functions and datatypes</h2><div class="top"><p class="src"><a id="v:enter" class="def">enter</a> :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-Utils-Enter.html#t:Enter">Enter</a> typ arg ret =&gt; arg -&gt; typ -&gt; ret <a href="#v:enter" class="selflink">#</a></p></div><div class="top"><p class="src"><span class="keyword">newtype</span> m <a id="t::-126--62-" class="def">:~&gt;</a> n :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) -&gt; (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t::-126--62-" class="selflink">#</a></p><div class="doc"><p>A natural transformation from <code>m</code> to <code>n</code>. Used to <code><a href="Servant-Server.html#v:enter">enter</a></code> particular
 datatypes.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:Nat" class="def">Nat</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><ul><li><dfn class="src"><a id="v:unNat" class="def">unNat</a> :: <span class="keyword">forall</span> a. m a -&gt; n a</dfn><div class="doc empty">&nbsp;</div></li></ul></div></td></tr></table></div><div class="subs instances"><p id="control.i::-126--62-" class="caption collapser" onclick="toggleSection('i::-126--62-')">Instances</p><div id="section.i::-126--62-" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id::-126--62-:Enter:1" class="instance expander" onclick="toggleSection('i:id::-126--62-:Enter:1')"></span> <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-Utils-Enter.html#t:Enter">Enter</a> (m a) (<a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> m n) (n a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id::-126--62-:Enter:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:enter">enter</a> :: (m <a href="Servant-Server.html#t::-126--62-">:~&gt;</a> n) -&gt; m a -&gt; n a <a href="#v:enter" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id::-126--62-:Category:2" class="instance expander" onclick="toggleSection('i:id::-126--62-:Category:2')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Category.html#t:Category">Category</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id::-126--62-:Category:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:id">id</a> :: cat a a <a href="#v:id" class="selflink">#</a></p><p class="src"><a href="#v:.">(.)</a> :: cat b c -&gt; cat a b -&gt; cat a c <a href="#v:." class="selflink">#</a></p></div></div></td></tr></table></div></div></div><h2 id="g:7"><code><a href="Servant-Server.html#v:Nat">Nat</a></code> utilities</h2><div class="top"><p class="src"><a id="v:liftNat" class="def">liftNat</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#t:MonadTrans">MonadTrans</a> t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m) =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> m (t m) <a href="#v:liftNat" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#v:lift">lift</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:runReaderTNat" class="def">runReaderTNat</a> :: r -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m) m <a href="#v:runReaderTNat" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:evalStateTLNat" class="def">evalStateTLNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; s -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m) m <a href="#v:evalStateTLNat" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:evalStateTSNat" class="def">evalStateTSNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; s -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Strict.html#t:StateT">StateT</a> s m) m <a href="#v:evalStateTSNat" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:logWriterTLNat" class="def">logWriterTLNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> m =&gt; (w -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> ()) -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m) m <a href="#v:logWriterTLNat" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="Servant-Server.html#v:logWriterTSNat">logWriterTSNat</a></code>, but for strict <code>WriterT</code>.</p></div></div><div class="top"><p class="src"><a id="v:logWriterTSNat" class="def">logWriterTSNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-IO-Class.html#t:MonadIO">MonadIO</a> m =&gt; (w -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> ()) -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m) m <a href="#v:logWriterTSNat" class="selflink">#</a></p><div class="doc"><p>Log the contents of <code><a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a></code> with the function provided as the
 first argument, and return the value of the <code>WriterT</code> computation</p></div></div><h2 id="g:8">Functions based on <a href="https://hackage.haskell.org/package/mmorph">mmorph</a></h2><div class="top"><p class="src"><a id="v:hoistNat" class="def">hoistNat</a> :: (MFunctor t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m) =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> m n -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (t m) (t n) <a href="#v:hoistNat" class="selflink">#</a></p><div class="doc"><p>Like <code>mmorph</code>'s <code>hoist</code>.</p></div></div><div class="top"><p class="src"><a id="v:embedNat" class="def">embedNat</a> :: (MMonad t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> n) =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> m (t n) -&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (t m) (t n) <a href="#v:embedNat" class="selflink">#</a></p><div class="doc"><p>Like <code>mmorph</code>'s <code>embed</code>.</p></div></div><div class="top"><p class="src"><a id="v:squashNat" class="def">squashNat</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m, MMonad t) =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> (t (t m)) (t m) <a href="#v:squashNat" class="selflink">#</a></p><div class="doc"><p>Like <code>mmorph</code>'s <code>squash</code>.</p></div></div><div class="top"><p class="src"><a id="v:generalizeNat" class="def">generalizeNat</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Applicative.html#t:Applicative">Applicative</a> m =&gt; <a href="Servant-Server.html#t::-126--62-">(:~&gt;)</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Identity.html#t:Identity">Identity</a> m <a href="#v:generalizeNat" class="selflink">#</a></p><div class="doc"><p>Like <code>mmorph</code>'s <code>generalize</code>.</p></div></div><div class="top"><p class="src"><a id="v:tweakResponse" class="def">tweakResponse</a> :: (<a href="Servant-Server-Internal-RoutingApplication.html#t:RouteResult">RouteResult</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Response">Response</a> -&gt; <a href="Servant-Server-Internal-RoutingApplication.html#t:RouteResult">RouteResult</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Response">Response</a>) -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env -&gt; <a href="Servant-Server-Internal-Router.html#t:Router">Router</a> env <a href="src/Servant-Server-Internal-Router.html#tweakResponse" class="link">Source</a> <a href="#v:tweakResponse" class="selflink">#</a></p><div class="doc"><p>Apply a transformation to the response of a <code><a href="Servant-Server-Internal-Router.html#t:Router">Router</a></code>.</p></div></div><h1 id="g:9">Context</h1><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Context" class="def">Context</a> contextTypes <span class="keyword">where</span> <a href="src/Servant-Server-Internal-Context.html#Context" class="link">Source</a> <a href="#t:Context" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#t:Context">Context</a></code>s are used to pass values to combinators. (They are <strong>not</strong> meant
 to be used to pass parameters to your handlers, i.e. they should not replace
 any custom <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Reader.html#v:ReaderT">ReaderT</a></code>-monad-stack that you're using
 with <code><a href="Servant-Utils.html#v:Enter">Enter</a></code>.) If you don't use combinators that
 require any context entries, you can just use <code><a href="Servant-Server.html#v:serve">serve</a></code> as always.</p><p>If you are using combinators that require a non-empty <code><a href="Servant-Server.html#t:Context">Context</a></code> you have to
 use <code><a href="Servant-Server.html#v:serveWithContext">serveWithContext</a></code> and pass it a <code><a href="Servant-Server.html#t:Context">Context</a></code> that contains all
 the values your combinators need. A <code><a href="Servant-Server.html#t:Context">Context</a></code> is essentially a heterogenous
 list and accessing the elements is being done by type (see <code><a href="Servant-Server.html#v:getContextEntry">getContextEntry</a></code>).
 The parameter of the type <code><a href="Servant-Server.html#t:Context">Context</a></code> is a type-level list reflecting the types
 of the contained context entries. To create a <code><a href="Servant-Server.html#t:Context">Context</a></code> with entries, use the
 operator <code>(<code><a href="Servant-Server.html#v::.">:.</a></code>)</code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:type True :. () :. EmptyContext
</code></strong>True :. () :. EmptyContext :: Context '[Bool, ()]
</pre></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:EmptyContext" class="def">EmptyContext</a> :: <a href="Servant-Server.html#t:Context">Context</a> '[]</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a id="v::." class="def">(:.)</a> :: x -&gt; <a href="Servant-Server.html#t:Context">Context</a> xs -&gt; <a href="Servant-Server.html#t:Context">Context</a> (x ': xs) <span class="fixity">infixr 5</span><span class="rightedge"></span></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:Context" class="caption collapser" onclick="toggleSection('i:Context')">Instances</p><div id="section.i:Context" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Context:Eq:1" class="instance expander" onclick="toggleSection('i:id:Context:Eq:1')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Servant-Server.html#t:Context">Context</a> as)) =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Servant-Server.html#t:Context">Context</a> ((:) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> a as))</span> <a href="src/Servant-Server-Internal-Context.html#line-48" class="link">Source</a> <a href="#t:Context" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Context:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="Servant-Server.html#t:Context">Context</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> ': a) as) -&gt; <a href="Servant-Server.html#t:Context">Context</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> ': a) as) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="Servant-Server.html#t:Context">Context</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> ': a) as) -&gt; <a href="Servant-Server.html#t:Context">Context</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> ': a) as) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Context:Eq:2" class="instance expander" onclick="toggleSection('i:id:Context:Eq:2')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Servant-Server.html#t:Context">Context</a> ([] <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>))</span> <a href="src/Servant-Server-Internal-Context.html#line-46" class="link">Source</a> <a href="#t:Context" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Context:Eq:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="Servant-Server.html#t:Context">Context</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>] -&gt; <a href="Servant-Server.html#t:Context">Context</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="Servant-Server.html#t:Context">Context</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>] -&gt; <a href="Servant-Server.html#t:Context">Context</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Context:Show:3" class="instance expander" onclick="toggleSection('i:id:Context:Show:3')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> a, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> (<a href="Servant-Server.html#t:Context">Context</a> as)) =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> (<a href="Servant-Server.html#t:Context">Context</a> ((:) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> a as))</span> <a href="src/Servant-Server-Internal-Context.html#line-41" class="link">Source</a> <a href="#t:Context" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Context:Show:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Servant-Server.html#t:Context">Context</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> ': a) as) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="Servant-Server.html#t:Context">Context</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> ': a) as) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="Servant-Server.html#t:Context">Context</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> ': a) as)] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Context:Show:4" class="instance expander" onclick="toggleSection('i:id:Context:Show:4')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> (<a href="Servant-Server.html#t:Context">Context</a> ([] <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>))</span> <a href="src/Servant-Server-Internal-Context.html#line-39" class="link">Source</a> <a href="#t:Context" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Context:Show:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Servant-Server.html#t:Context">Context</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="Servant-Server.html#t:Context">Context</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="Servant-Server.html#t:Context">Context</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a>]] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a id="t:HasContextEntry" class="def">HasContextEntry</a> context val <span class="keyword">where</span> <a href="src/Servant-Server-Internal-Context.html#HasContextEntry" class="link">Source</a> <a href="#t:HasContextEntry" class="selflink">#</a></p><div class="doc"><p>This class is used to access context entries in <code><a href="Servant-Server.html#t:Context">Context</a></code>s. <code><a href="Servant-Server.html#v:getContextEntry">getContextEntry</a></code>
 returns the first value where the type matches:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>getContextEntry (True :. False :. EmptyContext) :: Bool
</code></strong>True
</pre><p>If the <code><a href="Servant-Server.html#t:Context">Context</a></code> does not contain an entry of the requested type, you'll get
 an error:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>getContextEntry (True :. False :. EmptyContext) :: String
</code></strong>...
...No instance for (HasContextEntry '[] [Char])
...
</pre></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="Servant-Server.html#v:getContextEntry">getContextEntry</a></p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a id="v:getContextEntry" class="def">getContextEntry</a> :: <a href="Servant-Server.html#t:Context">Context</a> context -&gt; val <a href="src/Servant-Server-Internal-Context.html#getContextEntry" class="link">Source</a> <a href="#v:getContextEntry" class="selflink">#</a></p></div><div class="subs instances"><p id="control.i:HasContextEntry" class="caption collapser" onclick="toggleSection('i:HasContextEntry')">Instances</p><div id="section.i:HasContextEntry" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasContextEntry:HasContextEntry:1" class="instance expander" onclick="toggleSection('i:ic:HasContextEntry:HasContextEntry:1')"></span> <a href="Servant-Server.html#t:HasContextEntry">HasContextEntry</a> ((:) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> val xs) val</span> <a href="src/Servant-Server-Internal-Context.html#line-72" class="link">Source</a> <a href="#t:HasContextEntry" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:HasContextEntry:HasContextEntry:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:getContextEntry">getContextEntry</a> :: <a href="Servant-Server.html#t:Context">Context</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> ': val) xs) -&gt; val <a href="src/Servant-Server-Internal-Context.html#getContextEntry" class="link">Source</a> <a href="#v:getContextEntry" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:HasContextEntry:HasContextEntry:2" class="instance expander" onclick="toggleSection('i:ic:HasContextEntry:HasContextEntry:2')"></span> <a href="Servant-Server.html#t:HasContextEntry">HasContextEntry</a> xs val =&gt; <a href="Servant-Server.html#t:HasContextEntry">HasContextEntry</a> ((:) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> notIt xs) val</span> <a href="src/Servant-Server-Internal-Context.html#line-68" class="link">Source</a> <a href="#t:HasContextEntry" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:HasContextEntry:HasContextEntry:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:getContextEntry">getContextEntry</a> :: <a href="Servant-Server.html#t:Context">Context</a> ((<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> ': notIt) xs) -&gt; val <a href="src/Servant-Server-Internal-Context.html#getContextEntry" class="link">Source</a> <a href="#v:getContextEntry" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><h2 id="g:10">NamedContext</h2><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:NamedContext" class="def">NamedContext</a> name subContext <a href="src/Servant-Server-Internal-Context.html#NamedContext" class="link">Source</a> <a href="#t:NamedContext" class="selflink">#</a></p><div class="doc"><p>Normally context entries are accessed by their types. In case you need
 to have multiple values of the same type in your <code><a href="Servant-Server.html#t:Context">Context</a></code> and need to access
 them, we provide <code><a href="Servant-Server.html#t:NamedContext">NamedContext</a></code>. You can think of it as sub-namespaces for
 <code><a href="Servant-Server.html#t:Context">Context</a></code>s.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:NamedContext" class="def">NamedContext</a> (<a href="Servant-Server.html#t:Context">Context</a> subContext)</td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="top"><p class="src"><a id="v:descendIntoNamedContext" class="def">descendIntoNamedContext</a> :: <span class="keyword">forall</span> context name subContext. <a href="Servant-Server.html#t:HasContextEntry">HasContextEntry</a> context (<a href="Servant-Server.html#t:NamedContext">NamedContext</a> name subContext) =&gt; <a href="Servant.html#t:Proxy">Proxy</a> (name :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:Symbol">Symbol</a>) -&gt; <a href="Servant-Server.html#t:Context">Context</a> context -&gt; <a href="Servant-Server.html#t:Context">Context</a> subContext <a href="src/Servant-Server-Internal-Context.html#descendIntoNamedContext" class="link">Source</a> <a href="#v:descendIntoNamedContext" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:descendIntoNamedContext">descendIntoNamedContext</a></code> allows you to access <code><a href="Servant-Server.html#t:NamedContext">NamedContext</a></code>s. Usually you
 won't have to use it yourself but instead use a combinator like
 <code><a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-WithNamedContext.html#v:WithNamedContext">WithNamedContext</a></code>.</p><p>This is how <code><a href="Servant-Server.html#v:descendIntoNamedContext">descendIntoNamedContext</a></code> works:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:set -XFlexibleContexts
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let subContext = True :. EmptyContext
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:type subContext
</code></strong>subContext :: Context '[Bool]
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let parentContext = False :. (NamedContext subContext :: NamedContext &quot;subContext&quot; '[Bool]) :. EmptyContext
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:type parentContext
</code></strong>parentContext :: Context '[Bool, NamedContext &quot;subContext&quot; '[Bool]]
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>descendIntoNamedContext (Proxy :: Proxy &quot;subContext&quot;) parentContext :: Context '[Bool]
</code></strong>True :. EmptyContext
</pre></div></div><h1 id="g:11">Basic Authentication</h1><div class="top"><p class="src"><span class="keyword">newtype</span> <a id="t:BasicAuthCheck" class="def">BasicAuthCheck</a> usr <a href="src/Servant-Server-Internal-BasicAuth.html#BasicAuthCheck" class="link">Source</a> <a href="#t:BasicAuthCheck" class="selflink">#</a></p><div class="doc"><p>Datatype wrapping a function used to check authentication.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:BasicAuthCheck" class="def">BasicAuthCheck</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><ul><li><dfn class="src"><a id="v:unBasicAuthCheck" class="def">unBasicAuthCheck</a> :: <a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-BasicAuth.html#t:BasicAuthData">BasicAuthData</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr)</dfn><div class="doc empty">&nbsp;</div></li></ul></div></td></tr></table></div><div class="subs instances"><p id="control.i:BasicAuthCheck" class="caption collapser" onclick="toggleSection('i:BasicAuthCheck')">Instances</p><div id="section.i:BasicAuthCheck" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:BasicAuthCheck:Functor:1" class="instance expander" onclick="toggleSection('i:id:BasicAuthCheck:Functor:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> <a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a></span> <a href="src/Servant-Server-Internal-BasicAuth.html#line-42" class="link">Source</a> <a href="#t:BasicAuthCheck" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:BasicAuthCheck:Functor:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> a -&gt; <a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> b -&gt; <a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:BasicAuthCheck:Generic:2" class="instance expander" onclick="toggleSection('i:id:BasicAuthCheck:Generic:2')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Generic">Generic</a> (<a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> usr)</span> <a href="src/Servant-Server-Internal-BasicAuth.html#line-42" class="link">Source</a> <a href="#t:BasicAuthCheck" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:BasicAuthCheck:Generic:2" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> usr) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:Rep" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:from">from</a> :: <a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> usr -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> usr) x <a href="#v:from" class="selflink">#</a></p><p class="src"><a href="#v:to">to</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> usr) x -&gt; <a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> usr <a href="#v:to" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:BasicAuthCheck:Rep:3" class="instance expander" onclick="toggleSection('i:id:BasicAuthCheck:Rep:3')"></span> <span class="keyword">type</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> usr)</span> <a href="src/Servant-Server-Internal-BasicAuth.html#line-38" class="link">Source</a> <a href="#t:BasicAuthCheck" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:BasicAuthCheck:Rep:3" class="inst-details hide"><div class="src"><span class="keyword">type</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthCheck">BasicAuthCheck</a> usr) = <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:D1">D1</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:MetaData">MetaData</a> &quot;BasicAuthCheck&quot; &quot;Servant.Server.Internal.BasicAuth&quot; &quot;servant-server-0.8.1-2LHkbrY1twbE52cPHHmPEW&quot; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#v:True">True</a>) (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:C1">C1</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:MetaCons">MetaCons</a> &quot;BasicAuthCheck&quot; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:PrefixI">PrefixI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#v:True">True</a>) (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:S1">S1</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:MetaSel">MetaSel</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Maybe.html#v:Just">Just</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:Symbol">Symbol</a> &quot;unBasicAuthCheck&quot;) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:NoSourceUnpackedness">NoSourceUnpackedness</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:NoSourceStrictness">NoSourceStrictness</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:DecidedLazy">DecidedLazy</a>) (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rec0">Rec0</a> (<a href="file:///usr/share/doc/libghc-servant-doc/html/Servant-API-BasicAuth.html#t:BasicAuthData">BasicAuthData</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr)))))</div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:BasicAuthResult" class="def">BasicAuthResult</a> usr <a href="src/Servant-Server-Internal-BasicAuth.html#BasicAuthResult" class="link">Source</a> <a href="#t:BasicAuthResult" class="selflink">#</a></p><div class="doc"><p>servant-server's current implementation of basic authentication is not
 immune to certian kinds of timing attacks. Decoding payloads does not take
 a fixed amount of time.</p><p>The result of authentication/authorization</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:Unauthorized" class="def">Unauthorized</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a id="v:BadPassword" class="def">BadPassword</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a id="v:NoSuchUser" class="def">NoSuchUser</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a id="v:Authorized" class="def">Authorized</a> usr</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:BasicAuthResult" class="caption collapser" onclick="toggleSection('i:BasicAuthResult')">Instances</p><div id="section.i:BasicAuthResult" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:BasicAuthResult:Functor:1" class="instance expander" onclick="toggleSection('i:id:BasicAuthResult:Functor:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a></span> <a href="src/Servant-Server-Internal-BasicAuth.html#line-35" class="link">Source</a> <a href="#t:BasicAuthResult" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:BasicAuthResult:Functor:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> a -&gt; <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> b -&gt; <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:BasicAuthResult:Eq:2" class="instance expander" onclick="toggleSection('i:id:BasicAuthResult:Eq:2')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> usr =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr)</span> <a href="src/Servant-Server-Internal-BasicAuth.html#line-35" class="link">Source</a> <a href="#t:BasicAuthResult" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:BasicAuthResult:Eq:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr -&gt; <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr -&gt; <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:BasicAuthResult:Read:3" class="instance expander" onclick="toggleSection('i:id:BasicAuthResult:Read:3')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Read.html#t:Read">Read</a> usr =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Read.html#t:Read">Read</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr)</span> <a href="src/Servant-Server-Internal-BasicAuth.html#line-35" class="link">Source</a> <a href="#t:BasicAuthResult" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:BasicAuthResult:Read:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr) <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr) <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:BasicAuthResult:Show:4" class="instance expander" onclick="toggleSection('i:id:BasicAuthResult:Show:4')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> usr =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr)</span> <a href="src/Servant-Server-Internal-BasicAuth.html#line-35" class="link">Source</a> <a href="#t:BasicAuthResult" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:BasicAuthResult:Show:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:BasicAuthResult:Generic:5" class="instance expander" onclick="toggleSection('i:id:BasicAuthResult:Generic:5')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Generic">Generic</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr)</span> <a href="src/Servant-Server-Internal-BasicAuth.html#line-35" class="link">Source</a> <a href="#t:BasicAuthResult" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:BasicAuthResult:Generic:5" class="inst-details hide"><div class="subs associated-types"><p class="caption">Associated Types</p><p class="src"><span class="keyword">type</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr) :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:Rep" class="selflink">#</a></p></div> <div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:from">from</a> :: <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr) x <a href="#v:from" class="selflink">#</a></p><p class="src"><a href="#v:to">to</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr) x -&gt; <a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr <a href="#v:to" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:BasicAuthResult:Rep:6" class="instance expander" onclick="toggleSection('i:id:BasicAuthResult:Rep:6')"></span> <span class="keyword">type</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr)</span> <a href="src/Servant-Server-Internal-BasicAuth.html#line-30" class="link">Source</a> <a href="#t:BasicAuthResult" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:BasicAuthResult:Rep:6" class="inst-details hide"><div class="src"><span class="keyword">type</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rep">Rep</a> (<a href="Servant-Server.html#t:BasicAuthResult">BasicAuthResult</a> usr) = <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:D1">D1</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:MetaData">MetaData</a> &quot;BasicAuthResult&quot; &quot;Servant.Server.Internal.BasicAuth&quot; &quot;servant-server-0.8.1-2LHkbrY1twbE52cPHHmPEW&quot; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#v:False">False</a>) (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t::-43-:">(:+:)</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t::-43-:">(:+:)</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:C1">C1</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:MetaCons">MetaCons</a> &quot;Unauthorized&quot; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:PrefixI">PrefixI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#v:False">False</a>) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:U1">U1</a>) (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:C1">C1</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:MetaCons">MetaCons</a> &quot;BadPassword&quot; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:PrefixI">PrefixI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#v:False">False</a>) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:U1">U1</a>)) (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t::-43-:">(:+:)</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:C1">C1</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:MetaCons">MetaCons</a> &quot;NoSuchUser&quot; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:PrefixI">PrefixI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#v:False">False</a>) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:U1">U1</a>) (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:C1">C1</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:MetaCons">MetaCons</a> &quot;Authorized&quot; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:PrefixI">PrefixI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#v:False">False</a>) (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:S1">S1</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:MetaSel">MetaSel</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Maybe.html#v:Nothing">Nothing</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-TypeLits.html#t:Symbol">Symbol</a>) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:NoSourceUnpackedness">NoSourceUnpackedness</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:NoSourceStrictness">NoSourceStrictness</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#v:DecidedLazy">DecidedLazy</a>) (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/GHC-Generics.html#t:Rec0">Rec0</a> usr)))))</div></div></td></tr></table></div></div></div><h1 id="g:12">General Authentication</h1><h1 id="g:13">Default error type</h1><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:ServantErr" class="def">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#ServantErr" class="link">Source</a> <a href="#t:ServantErr" class="selflink">#</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:ServantErr" class="def">ServantErr</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><ul><li><dfn class="src"><a id="v:errHTTPCode" class="def">errHTTPCode</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a></dfn><div class="doc empty">&nbsp;</div></li><li><dfn class="src"><a id="v:errReasonPhrase" class="def">errReasonPhrase</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a></dfn><div class="doc empty">&nbsp;</div></li><li><dfn class="src"><a id="v:errBody" class="def">errBody</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></dfn><div class="doc empty">&nbsp;</div></li><li><dfn class="src"><a id="v:errHeaders" class="def">errHeaders</a> :: [<a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Header.html#t:Header">Header</a>]</dfn><div class="doc empty">&nbsp;</div></li></ul></div></td></tr></table></div><div class="subs instances"><p id="control.i:ServantErr" class="caption collapser" onclick="toggleSection('i:ServantErr')">Instances</p><div id="section.i:ServantErr" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ServantErr:Eq:1" class="instance expander" onclick="toggleSection('i:id:ServantErr:Eq:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> <a href="Servant-Server.html#t:ServantErr">ServantErr</a></span> <a href="src/Servant-Server-Internal-ServantErr.html#line-18" class="link">Source</a> <a href="#t:ServantErr" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:ServantErr:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> -&gt; <a href="Servant-Server.html#t:ServantErr">ServantErr</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> -&gt; <a href="Servant-Server.html#t:ServantErr">ServantErr</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ServantErr:Read:2" class="instance expander" onclick="toggleSection('i:id:ServantErr:Read:2')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Read.html#t:Read">Read</a> <a href="Servant-Server.html#t:ServantErr">ServantErr</a></span> <a href="src/Servant-Server-Internal-ServantErr.html#line-18" class="link">Source</a> <a href="#t:ServantErr" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:ServantErr:Read:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="Servant-Server.html#t:ServantErr">ServantErr</a>] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="Servant-Server.html#t:ServantErr">ServantErr</a>] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ServantErr:Show:3" class="instance expander" onclick="toggleSection('i:id:ServantErr:Show:3')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:Show">Show</a> <a href="Servant-Server.html#t:ServantErr">ServantErr</a></span> <a href="src/Servant-Server-Internal-ServantErr.html#line-18" class="link">Source</a> <a href="#t:ServantErr" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:ServantErr:Show:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Servant-Server.html#t:ServantErr">ServantErr</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="Servant-Server.html#t:ServantErr">ServantErr</a>] -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ServantErr:Exception:4" class="instance expander" onclick="toggleSection('i:id:ServantErr:Exception:4')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Exception-Base.html#t:Exception">Exception</a> <a href="Servant-Server.html#t:ServantErr">ServantErr</a></span> <a href="src/Servant-Server-Internal-ServantErr.html#line-20" class="link">Source</a> <a href="#t:ServantErr" class="selflink">#</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:ServantErr:Exception:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toException">toException</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Exception-Base.html#t:SomeException">SomeException</a> <a href="#v:toException" class="selflink">#</a></p><p class="src"><a href="#v:fromException">fromException</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Exception-Base.html#t:SomeException">SomeException</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="#v:fromException" class="selflink">#</a></p><p class="src"><a href="#v:displayException">displayException</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a> <a href="#v:displayException" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><h2 id="g:14">3XX</h2><div class="top"><p class="src"><a id="v:err300" class="def">err300</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err300" class="link">Source</a> <a href="#v:err300" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err300">err300</a></code> Multiple Choices</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err300 { errBody = &quot;I can't choose.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err301" class="def">err301</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err301" class="link">Source</a> <a href="#v:err301" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err301">err301</a></code> Moved Permanently</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError err301</pre></div></div><div class="top"><p class="src"><a id="v:err302" class="def">err302</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err302" class="link">Source</a> <a href="#v:err302" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err302">err302</a></code> Found</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError err302</pre></div></div><div class="top"><p class="src"><a id="v:err303" class="def">err303</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err303" class="link">Source</a> <a href="#v:err303" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err303">err303</a></code> See Other</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError err303</pre></div></div><div class="top"><p class="src"><a id="v:err304" class="def">err304</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err304" class="link">Source</a> <a href="#v:err304" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err304">err304</a></code> Not Modified</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError err304</pre></div></div><div class="top"><p class="src"><a id="v:err305" class="def">err305</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err305" class="link">Source</a> <a href="#v:err305" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err305">err305</a></code> Use Proxy</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError err305</pre></div></div><div class="top"><p class="src"><a id="v:err307" class="def">err307</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err307" class="link">Source</a> <a href="#v:err307" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err307">err307</a></code> Temporary Redirect</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError err307</pre></div></div><h2 id="g:15">4XX</h2><div class="top"><p class="src"><a id="v:err400" class="def">err400</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err400" class="link">Source</a> <a href="#v:err400" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err400">err400</a></code> Bad Request</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err400 { errBody = &quot;Your request makes no sense to me.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err401" class="def">err401</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err401" class="link">Source</a> <a href="#v:err401" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err401">err401</a></code> Unauthorized</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err401 { errBody = &quot;Your credentials are invalid.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err402" class="def">err402</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err402" class="link">Source</a> <a href="#v:err402" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err402">err402</a></code> Payment Required</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err402 { errBody = &quot;You have 0 credits. Please give me $$$.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err403" class="def">err403</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err403" class="link">Source</a> <a href="#v:err403" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err403">err403</a></code> Forbidden</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err403 { errBody = &quot;Please login first.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err404" class="def">err404</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err404" class="link">Source</a> <a href="#v:err404" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err404">err404</a></code> Not Found</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err404 { errBody = &quot;(&#9583;&#176;&#9633;&#176;&#65289;&#9583;&#65077; &#9531;&#9473;&#9531;).&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err405" class="def">err405</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err405" class="link">Source</a> <a href="#v:err405" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err405">err405</a></code> Method Not Allowed</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err405 { errBody = &quot;Your account privileges does not allow for this.  Please pay $$$.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err406" class="def">err406</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err406" class="link">Source</a> <a href="#v:err406" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err406">err406</a></code> Not Acceptable</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError err406</pre></div></div><div class="top"><p class="src"><a id="v:err407" class="def">err407</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err407" class="link">Source</a> <a href="#v:err407" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err407">err407</a></code> Proxy Authentication Required</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError err407</pre></div></div><div class="top"><p class="src"><a id="v:err409" class="def">err409</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err409" class="link">Source</a> <a href="#v:err409" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err409">err409</a></code> Conflict</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err409 { errBody = &quot;Transaction conflicts with 59879cb56c7c159231eeacdd503d755f7e835f74&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err410" class="def">err410</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err410" class="link">Source</a> <a href="#v:err410" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err410">err410</a></code> Gone</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err410 { errBody = &quot;I know it was here at some point, but.. I blame bad luck.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err411" class="def">err411</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err411" class="link">Source</a> <a href="#v:err411" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err411">err411</a></code> Length Required</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError err411</pre></div></div><div class="top"><p class="src"><a id="v:err412" class="def">err412</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err412" class="link">Source</a> <a href="#v:err412" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err412">err412</a></code> Precondition Failed</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err412 { errBody = &quot;Precondition fail: x &lt; 42 &amp;&amp; y &gt; 57&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err413" class="def">err413</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err413" class="link">Source</a> <a href="#v:err413" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err413">err413</a></code> Request Entity Too Large</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err413 { errBody = &quot;Request exceeded 64k.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err414" class="def">err414</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err414" class="link">Source</a> <a href="#v:err414" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err414">err414</a></code> Request-URI Too Large</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err414 { errBody = &quot;Maximum length is 64.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err415" class="def">err415</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err415" class="link">Source</a> <a href="#v:err415" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err415">err415</a></code> Unsupported Media Type</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err415 { errBody = &quot;Supported media types:  gif, png&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err416" class="def">err416</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err416" class="link">Source</a> <a href="#v:err416" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err416">err416</a></code> Request range not satisfiable</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err416 { errBody = &quot;Valid range is [0, 424242].&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err417" class="def">err417</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err417" class="link">Source</a> <a href="#v:err417" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err417">err417</a></code> Expectation Failed</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err417 { errBody = &quot;I found a quux in the request.  This isn't going to work.&quot; }</pre></div></div><h2 id="g:16">5XX</h2><div class="top"><p class="src"><a id="v:err500" class="def">err500</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err500" class="link">Source</a> <a href="#v:err500" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err500">err500</a></code> Internal Server Error</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err500 { errBody = &quot;Exception in module A.B.C:55.  Have a great day!&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err501" class="def">err501</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err501" class="link">Source</a> <a href="#v:err501" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err501">err501</a></code> Not Implemented</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err501 { errBody = &quot;/v1/foo is not supported with quux in the request.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err502" class="def">err502</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err502" class="link">Source</a> <a href="#v:err502" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err502">err502</a></code> Bad Gateway</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err502 { errBody = &quot;Tried gateway foo, bar, and baz.  None responded.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err503" class="def">err503</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err503" class="link">Source</a> <a href="#v:err503" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err503">err503</a></code> Service Unavailable</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err503 { errBody = &quot;We're rewriting in PHP.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err504" class="def">err504</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err504" class="link">Source</a> <a href="#v:err504" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err504">err504</a></code> Gateway Time-out</p><p>Example:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err504 { errBody = &quot;Backend foobar did not respond in 5 seconds.&quot; }</pre></div></div><div class="top"><p class="src"><a id="v:err505" class="def">err505</a> :: <a href="Servant-Server.html#t:ServantErr">ServantErr</a> <a href="src/Servant-Server-Internal-ServantErr.html#err505" class="link">Source</a> <a href="#v:err505" class="selflink">#</a></p><div class="doc"><p><code><a href="Servant-Server.html#v:err505">err505</a></code> HTTP Version not supported</p><p>Example usage:</p><pre>failingHandler :: Handler ()
failingHandler = throwError $ err505 { errBody = &quot;I support HTTP/4.0 only.&quot; }</pre></div></div><h1 id="g:17">Re-exports</h1><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:Application" class="def">Application</a> = <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Request">Request</a> -&gt; (<a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Response">Response</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:ResponseReceived">ResponseReceived</a>) -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:ResponseReceived">ResponseReceived</a> <a href="#t:Application" class="selflink">#</a></p><div class="doc"><p>The WAI application.</p><p>Note that, since WAI 3.0, this type is structured in continuation passing
 style to allow for proper safe resource handling. This was handled in the
 past via other means (e.g., <code>ResourceT</code>). As a demonstration:</p><pre>app :: Application
app req respond = bracket_
    (putStrLn &quot;Allocating scarce resource&quot;)
    (putStrLn &quot;Cleaning up&quot;)
    (respond $ responseLBS status200 [] &quot;Hello World&quot;)
</pre></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>