|
|
|
|
|
by boucher
6350 days ago
|
|
Sinatra is definitely an interesting project. We recently "ported" it to JavaScript: http://github.com/tlrobinson/jack/blob/030685ef3de4c29c38b4e... The same webservice would be: roundabout.route({ path:"/add/{a}/{b}", get: function(){this.body = this.wildcards["a"] + this.wildcards["b"];} })
or, alternatively: roundabout.get("/add/{a}/{b}", function(){ this.body = this.wildcards.a + this.wildcards.b; });
The first syntax is a tad longer, but its much more useful; you can define any method with the name of an HTTP verb for that path, and you can also define a filter parameter that will be queried before the path is matched. The filter lets you do whatever pre-processing you want, so you could filter out requests from a specific user-agent for example, or all URLs that use mixed case, or anything else you can think of. |
|