Update some docs and the changelogs

This commit is contained in:
Luke Cycon 2016-04-11 11:19:18 -07:00
parent f484483d84
commit 353c1798e1
4 changed files with 21 additions and 5 deletions

View file

@ -44,7 +44,7 @@ You can use this combinator to protect an API as follows:
module Authentication where
import Control.Monad.Trans.Except (ExceptT, throwE)
import Control.Monad.Trans.Except (ExceptT)
import Data.Aeson (ToJSON)
import Data.ByteString (ByteString)
import Data.Map (Map, fromList)
@ -59,6 +59,7 @@ import Servant.API ((:<|>) ((:<|>)), (:>), BasicAuth,
Get, JSON)
import Servant.API.BasicAuth (BasicAuthData (BasicAuthData))
import Servant.API.Experimental.Auth (AuthProtect)
import Servant (throwError)
import Servant.Server (BasicAuthCheck (BasicAuthCheck),
BasicAuthResult( Authorized
, Unauthorized
@ -274,7 +275,7 @@ database = fromList [ ("key1", Account "Anne Briggs")
-- This is our bespoke (and bad) authentication logic.
lookupAccount :: ByteString -> ExceptT ServantErr IO Account
lookupAccount key = case Map.lookup key database of
Nothing -> throwE (err403 { errBody = "Invalid Cookie" })
Nothing -> throwError (err403 { errBody = "Invalid Cookie" })
Just usr -> return usr
```
@ -289,7 +290,7 @@ method:
authHandler :: AuthHandler Request Account
authHandler =
let handler req = case lookup "servant-auth-cookie" (requestHeaders req) of
Nothing -> throwE (err401 { errBody = "Missing auth header" })
Nothing -> throwError (err401 { errBody = "Missing auth header" })
Just authCookieKey -> lookupAccount authCookieKey
in mkAuthHandler handler
```

View file

@ -1,3 +1,8 @@
HEAD
----
* Export `throwError` from module `Servant`
0.5
----

View file

@ -1,3 +1,8 @@
HEAD
----
* Export `throwError` from module `Servant`
0.6
---

View file

@ -1,3 +1,8 @@
HEAD
----
* Export `throwError` from module `Servant`
0.5
----