-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(http): Move the handler creation of the http server to a file
- Loading branch information
Showing
2 changed files
with
31 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
let prelude = import! "std/prelude.glu" | ||
let { show } = prelude.show_Int | ||
let string = import! "std/string.glu" | ||
let { (<>) } = prelude.make_Monoid string.monoid | ||
|
||
let { (*>) } = prelude.make_Applicative prelude.applicative_IO | ||
|
||
let { | ||
StatusCode, | ||
handle, empty_response, get, get_request, path, listen, | ||
applicative, alternative, monad } = import! "examples/http.glu" | ||
|
||
let { (*>), pure } = prelude.make_Applicative applicative | ||
let { (<|>) } = prelude.make_Alternative alternative | ||
let { (>>=) } = prelude.make_Monad monad | ||
|
||
let handler = | ||
(get *> path "/" *> (pure { status = OK, body = "Hello World" })) <|> | ||
(get *> path "/error" *> (pure { status = InternalServerError, body = "Error" })) | ||
|
||
\port -> | ||
io.println ("Opened server on port " <> show port) *> | ||
listen port handler |