-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMain.purs
More file actions
26 lines (22 loc) · 1.11 KB
/
Copy pathMain.purs
File metadata and controls
26 lines (22 loc) · 1.11 KB
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
module Examples.PathSegments.Main where
import Prelude
import Effect.Console (log)
import HTTPure (Request, ResponseM, ServerM, ok, serve, (!@))
-- | Specify the routes
router :: Request -> ResponseM
router { path }
| path !@ 0 == "segment" = ok $ path !@ 1
| otherwise = ok $ show path
-- | Boot up the server
main :: ServerM
main =
serve 8080 router do
log " ┌───────────────────────────────────────────────┐"
log " │ Server now up on port 8080 │"
log " │ │"
log " │ To test, run: │"
log " │ > curl localhost:8080/segment/<anything> │"
log " │ # => <anything> │"
log " │ > curl localhost:8080/<anything>/<else>/... │"
log " │ # => [ <anything>, <else>, ... ] │"
log " └───────────────────────────────────────────────┘"