4 ms·
Sinatra is definitely an interesting project. We recently "ported" it to JavaScript: http://github.com/tlrobinson/jack/blob/030685ef3de4c29c38b4e2ce22f638b6985
by boucher 18y ago
Sinatra is definitely an interesting project. We recently "ported" it to JavaScript:
http://github.com/tlrobinson/jack/blob/030685ef3de4c29c38b4e2ce22f638b698532b2b/lib/roundabout.js 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.
- lsb 18y agoThat looks really cool; how's that been working out? Is that in production? If Ruby had Gambit Scheme's serializable continuations, that would be pretty interesting times.
- boucher 18y agoWe're not yet using it in production, its only a few weeks old, but we will be in some of the things we're working on. One of the main benefits is letting us run objective-j and cappuccino on the server, letting us share application data models in the client and the server.