Make server cancelable and clean up examples and tests (#112)
This commit is contained in:
@@ -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 $ " └────────────────────────────────────────────┘"
|
||||
|
||||
Reference in New Issue
Block a user