(: Aiche Tee Tee Pee :)
Perhaps the first webserver in Tree Calculus? Sure, it's married to a Haskell IO runtime... but we're managing all of the actual webserver semantics in tricu! This includes a demo Arboricx application server that is capable of storing and serving bundles.
This commit is contained in:
16
demos/interactionTrees/httpServer.tri
Normal file
16
demos/interactionTrees/httpServer.tri
Normal file
@@ -0,0 +1,16 @@
|
||||
!import "../lib/prelude.tri" !Local
|
||||
!import "../lib/io.tri" !Local
|
||||
!import "../lib/socket.tri" !Local
|
||||
!import "../lib/http.tri" !Local
|
||||
|
||||
myRouter = (method path headers body :
|
||||
matchBool
|
||||
(okResponse (append "Hello from " (append path "\n")))
|
||||
(methodNotAllowedResponse)
|
||||
(strEq? method "GET"))
|
||||
|
||||
main = io (
|
||||
onOk_ socket (server :
|
||||
onOk_ (bindSocket server "127.0.0.1" 9050) (_ :
|
||||
onOk_ (listen server 5) (_ :
|
||||
serveForever server (httpHandler myRouter)))))
|
||||
Reference in New Issue
Block a user