0 | module HTTP.API.Server.Env
 1 |
 2 | import HTTP.API.Server.Interface
 3 | import System.Clock
 4 |
 5 | %default total
 6 |
 7 | public export
 8 | interface LoadEnv (0 a : Type) where
 9 |   loadEnv : HTTPProg [RequestErr] a
10 |
11 | export %inline
12 | LoadEnv ReqTime where
13 |   loadEnv = RT <$> liftIO (clockTime UTC)
14 |
15 | public export
16 | Serve ReqEnv where
17 |   Constraint b         = LoadEnv b.type
18 |   InTypes  b           = [b.type]
19 |   OutTypes _           = []
20 |   outs     _           = %search
21 |   canHandle   _ r      = True
22 |   fromRequest _ r      = map (\x => [x]) loadEnv
23 |   adjResponse _ [] req = pure
24 |