32 lines
1.1 KiB
Haskell
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: 8080, onStarted } { route, router: const $ ok "hello world!" }
|
|
where
|
|
onStarted = do
|
|
log " ┌────────────────────────────────────────────┐"
|
|
log " │ Server now up on port 8080 │"
|
|
log " │ │"
|
|
log " │ To test, run: │"
|
|
log " │ > curl localhost:8080 # => hello world! │"
|
|
log " └────────────────────────────────────────────┘"
|