I'm currently working on the stable version of Rascal and I want to spawn the Rascal webserver to serve my html templates with javascript functions.
Looking at the Webserver module I can't see how to use the serve function to use the webserver. It asks for a location (I'm assuming that the location would be something like |http://localhost:8080|
) and a callback that has the type of Response (Request)
but what is that type? I don't know how to create this kind of type and what it exactly is.
The type
Response (Request) callbackis a function, E.g.:
Response (Request r) { return response(...); }
This function is an anonymous function (it has no name) that you can pass into the serve function as an argument, you can also define it as a normal function with a name, and just put the name of that function as the argument.
So this would probably work:
serve(|http://localhost:8080|, Response (Request r){ return response("Hello world"); }):
Since there is a factory method
Response response(str content)in Webserver.rsc, that will create a response for you from a string argument.