forked from hoodunit/purescript-payload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.purs
38 lines (33 loc) · 1001 Bytes
/
Main.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module Payload.Examples.Files.Main where
import Data.Either (Either)
import Data.List (List)
import Effect.Aff (Aff)
import Payload.Server.Handlers (File)
import Payload.Server.Handlers as Handlers
import Payload.ResponseTypes (Failure)
import Payload.Spec (Spec(Spec), GET)
spec :: Spec
{ guards :: {}
, routes ::
{ indexPage :: GET "/"
{ response :: File }
, public :: GET "/<..path>"
{ params :: { path :: List String }
, response :: File }
}
}
spec = Spec
indexPage :: {} -> Aff File
indexPage = Handlers.file "examples/files/index.html"
public :: { params :: { path :: List String } } -> Aff (Either Failure File)
public { params: {path} } = Handlers.directory "examples/files/public" path
api ::
{ guards :: Record ()
, handlers ::
{ indexPage :: Record () -> Aff File
, public :: { params :: { path :: List String } } -> Aff (Either Failure File)
}
}
api =
{ handlers: { indexPage, public }
, guards: {} }