0 | module HTTP.API.Server
2 | import public HTTP.API
3 | import public HTTP.API.Server.Content
4 | import public HTTP.API.Server.Env
5 | import public HTTP.API.Server.Header
6 | import public HTTP.API.Server.Interface
7 | import public HTTP.API.Server.Method
8 | import public HTTP.API.Server.Path
9 | import public HTTP.API.Server.Query
10 | import public HTTP.Prog
11 | import public HTTP.Request
12 | import public HTTP.Response
17 | data Server : Endpoints -> Type where
21 | -> {0 as : Endpoints}
22 | -> {endpoint : HList ts}
23 | -> {auto all : All Serve ts}
24 | -> {auto con : HList (Constraints endpoint)}
25 | -> EndpointHandler endpoint
27 | -> Server (endpoint :: as)
30 | (++) : Server es -> Server fs -> Server (es ++ fs)
32 | (++) (s::ss) sfs = s :: (ss ++ sfs)
36 | (0 endpoints : Endpoints)
40 | serveAll [] [] req = throw (requestErr notFound404)
41 | serveAll (endpoint :: as) ((::) {endpoint} f x) req =
42 | case canServe endpoint req of
43 | True => serveEndpoint endpoint f req
44 | False => serveAll as x req