]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Resource/CheckAuth.hs
basic authorization support
[Rakka.git] / Rakka / Resource / CheckAuth.hs
1 module Rakka.Resource.CheckAuth
2     ( resCheckAuth
3     )
4     where
5
6 import           Network.HTTP.Lucu
7 import           Rakka.Environment
8 import           Rakka.Resource
9
10
11 resCheckAuth :: Environment -> ResourceDef
12 resCheckAuth env
13     = ResourceDef {
14         resUsesNativeThread = False
15       , resIsGreedy         = False
16       , resGet
17           = Just $
18             do userID <- getUserID env
19                case userID of
20                  Just _  -> setStatus NoContent
21                  Nothing -> setStatus Forbidden
22       , resHead             = Nothing
23       , resPost             = Nothing
24       , resPut              = Nothing
25       , resDelete           = Nothing
26       }