purescript-httpurple/test/example/HelloWorld/Main.purs

32 lines
1.1 KiB
Haskell

module Examples.HelloWorld.Main where
import Prelude
import Data.Generic.Rep (class Generic)
import Effect.Console (log)
import HTTPurple (ServerM, ok, serve)
import Routing.Duplex as RD
import Routing.Duplex.Generic as RG
data Route = SayHello
derive instance Generic Route _
route :: RD.RouteDuplex' Route
route = RD.root $ RG.sum
{ "SayHello": RG.noArgs
}
-- | Boot up the server
main :: ServerM
main =
serve { hostname: "localhost", port: 10000, onStarted } { route, router: const $ ok "hello world!" }
where
onStarted = do
log " ┌────────────────────────────────────────────┐"
log " │ Server now up on port 10000 │"
log " │ │"
log " │ To test, run: │"
log " │ > curl localhost:10000 # => hello world!│"
log " └────────────────────────────────────────────┘"