purescript-httpurple/docs/Examples/HelloWorld/Main.purs
2022-05-22 12:34:27 +01:00

31 lines
1.1 KiB
Haskell

module Examples.HelloWorld.Main where
import Prelude
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Effect.Console (log)
import HTTPure (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 8080 { route, router: const $ ok "hello world!", notFoundHandler: Nothing } do
log " ┌────────────────────────────────────────────┐"
log " │ Server now up on port 8080 │"
log " │ │"
log " │ To test, run: │"
log " │ > curl localhost:8080 # => hello world! │"
log " └────────────────────────────────────────────┘"