Simple Script for URI Handling

command linescripturl

Basically what I'd like to know is how can I setup a shell script (or an Applescript or Automator wrapper for a shell script) as a protocol handler for a custom URI (so clicking them will trigger my script) with the URI passed in as an argument?

For example, if my URI looked something like:

foo://haravikk.com/request?id=1234&name=bar

How could I setup a shell script on OS X to be triggered any time a URI with protocol "foo" is clicked, and to receive the entire URI as an argument I can then process? I already have the script for processing done, just don't know how to get it triggered in the first place 🙂