Make server cancelable and clean up examples and tests (#112)

This commit is contained in:
Connor Prussin
2018-09-02 14:05:54 -07:00
committed by GitHub
parent 1adbcecaaa
commit ce4a10a3b5
14 changed files with 122 additions and 205 deletions

View File

@@ -5,24 +5,12 @@ import Prelude
import Effect.Console as Console
import HTTPure as HTTPure
-- | Serve the example server on this port
port :: Int
port = 8080
-- | Shortcut for `show port`
portS :: String
portS = show port
-- | Say 'hello world!' when run
sayHello :: HTTPure.Request -> HTTPure.ResponseM
sayHello _ = HTTPure.ok "hello world!"
-- | Boot up the server
main :: HTTPure.ServerM
main = HTTPure.serve port sayHello do
main = HTTPure.serve 8080 (const $ HTTPure.ok "hello world!") do
Console.log $ " ┌────────────────────────────────────────────┐"
Console.log $ " │ Server now up on port " <> portS <> " │"
Console.log $ " │ Server now up on port 8080 │"
Console.log $ " │ │"
Console.log $ " │ To test, run: │"
Console.log $ " │ > curl localhost:" <> portS <> " # => hello world! │"
Console.log $ " │ > curl localhost:8080 # => hello world! │"
Console.log $ " └────────────────────────────────────────────┘"