Clean up basic-auth example
This commit is contained in:
parent
dc464fa480
commit
78da8e9a77
1 changed files with 15 additions and 14 deletions
|
@ -7,16 +7,21 @@
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Data.Aeson (ToJSON)
|
import Data.Aeson (ToJSON)
|
||||||
import Data.Proxy (Proxy (Proxy))
|
import Data.Proxy (Proxy (Proxy))
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import GHC.Generics (Generic)
|
import GHC.Generics (Generic)
|
||||||
import Network.Wai.Handler.Warp (run)
|
import Network.Wai.Handler.Warp (run)
|
||||||
import Servant.API ((:<|>) ((:<|>)), (:>), BasicAuth,
|
import Servant.API ((:<|>) ((:<|>)), (:>), BasicAuth,
|
||||||
Get, JSON)
|
Get, JSON)
|
||||||
import Servant.API.Auth (BasicAuthData(BasicAuthData))
|
import Servant.API.Auth (BasicAuthData (BasicAuthData))
|
||||||
import Servant.Server (AuthReturnType, BasicAuthResult (Authorized, Unauthorized), Config ((:.), EmptyConfig),
|
import Servant.Server (AuthReturnType,
|
||||||
Server, serve, BasicAuthCheck(BasicAuthCheck))
|
BasicAuthCheck (BasicAuthCheck),
|
||||||
|
BasicAuthResult( Authorized
|
||||||
|
, Unauthorized
|
||||||
|
),
|
||||||
|
Config ((:.), EmptyConfig), Server,
|
||||||
|
serve)
|
||||||
|
|
||||||
-- | let's define some types that our API returns.
|
-- | let's define some types that our API returns.
|
||||||
|
|
||||||
|
@ -50,10 +55,6 @@ type API = "public" :> PublicAPI
|
||||||
api :: Proxy API
|
api :: Proxy API
|
||||||
api = Proxy
|
api = Proxy
|
||||||
|
|
||||||
-- | a value holding a proxy of our basic auth realm.
|
|
||||||
authRealm :: Proxy "foo-realm"
|
|
||||||
authRealm = Proxy
|
|
||||||
|
|
||||||
-- | Specify the data type returned after performing basic authentication
|
-- | Specify the data type returned after performing basic authentication
|
||||||
type instance AuthReturnType (BasicAuth "foo-realm") = User
|
type instance AuthReturnType (BasicAuth "foo-realm") = User
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue