views:

64

answers:

2

I'm looking for some thin layer on top of handling HTTP requests that can easily do routing to different backends, based on the uri / rest verb / actual service location / .... This layer should also handle encoding into whatever the requested format is (xml / json / returning binary data / etc.).

The most important point though is to make it pluggable into some backend - whether it's a message queue, job dispatcher, external process, or something completely different. They should be handled with minimal wrapper for the needed message translation.

So basically, that would be a customisable request dispatcher with some magic on top. Does something like that exist as a separate application now?

Edit: Almost forgot - it would be great if it was written in PHP... but if something else matches the description, I'd have a look too.

+2  A: 

Don't know about PHP, but if Java and/or Python are acceptable options for you, you should take a look at RESTx, which was designed for the simple and fast creation of RESTful services. RESTx is fully open source, GPLv3 licensed.

I agree that many frameworks are all about object creation and mapping, which often can be very annoying and get in the way. RESTx, however, is about the data, the automatic conversion of content types and so on. With RESTx you can write custom components in either Java or Python. These components can take care of access to databases, custom APIs, legacy data, cloud services, etc. RESTx examines the code and automatically produces a self documented, discoverable, RESTful API. It's all links you can follow. Take a look at how to take a tour of the server with a web browser.

The key is that you can POST parameter sets to those components which are then stored and accessible under a new URI. You access the URI, the parameters get applied to the component and you get the output back. Thus, you can rapidly create new RESTful web services and resources. You can access other resources easily from within your component's code and it doesn't cause an additional HTTP request.

I'm the lead developer for RESTx, so if you have any questions about it, please contact me on the forums (links to those are on our web site).

jbrendel
This is really interesting... I'm a bit worried about this being self-running, not pluggable into a webserver, but otherwise it looks cool :)
viraptor
+1  A: 

Zed Shaw of Mongrel fame is attempting to do just this. He's creating Mongrel2 (still in development), essentially a universal frontend for web application backends. It allows you to plug in any program that can send and receive 0MQ or HTTP messages like a reverse proxy.

It also uses a sane configuration file system: SQLite. No more messing around with Apache config files with weird syntax.

It's written in C, so it may not be as easy to deploy as a language like PHP, but it certainly scales very well.

If you're not satisfied with Mongrel2, it's relatively easy to roll your own. I've used nodejitsu's node-http-proxy for one of my own projects. It's simple and fast. Plus, you can write your routing rules using regular old if statements.

I'm new to StackOverflow so it won't let me embed more than one hyperlink, haha.

CapnKernul