@@ -9,7 +9,8 @@ module Examples.AuthenticationAndAuthorization where
99
1010import Prelude
1111
12- import Control.Monad.Indexed ((:>>=), (:*>))
12+ import Control.Monad.Indexed.Qualified as Ix
13+ import Control.Monad.Indexed ((:>>=))
1314import Effect.Aff.Class (class MonadAff )
1415import Effect (Effect )
1516import Data.Either (Either (..))
@@ -45,11 +46,11 @@ htmlWithStatus
4546 (Conn req (res StatusLineOpen ) c )
4647 (Conn req (res ResponseEnded ) c )
4748 Unit
48- htmlWithStatus status x =
49+ htmlWithStatus status x = Ix . do
4950 writeStatus status
50- :*> contentType textHTML
51- :*> closeHeaders
52- :*> respond (render x)
51+ contentType textHTML
52+ closeHeaders
53+ respond (render x)
5354
5455
5556-- Users have user names.
@@ -76,11 +77,11 @@ profileHandler
7677 (Conn req (res StatusLineOpen ) { authentication :: Maybe User | c } )
7778 (Conn req (res ResponseEnded ) { authentication :: Maybe User | c } )
7879 Unit
79- profileHandler =
80- getConn :>>= \ conn →
80+ profileHandler = Ix . do
81+ conn <- getConn
8182 htmlWithStatus
82- statusOK
83- (view conn.components.authentication)
83+ statusOK
84+ (view conn.components.authentication)
8485 where
8586 view =
8687 case _ of
@@ -183,8 +184,8 @@ app = BasicAuth.withAuthentication userFromBasicAuth :>>= \_ → router
183184 li (a ! A .href " /profile" $ text " Profile" )
184185 li (a ! A .href " /admin" $ text " Administration" )
185186
186- router =
187- getRequestData :>>= \ { method, url } →
187+ router = Ix . do
188+ { method, url } <- getRequestData
188189 case method, url of
189190 Left GET , " /" ->
190191 htmlWithStatus statusOK homeView
0 commit comments