wip: Add rest api

Close #29
Implements #30 
I found this function more difficult to trace through than I would have expected.. I can't think of a fix, but if you're collecting votes on whether it could use a refactoring, you've got a +1 from me.

What tripped me up the most was the sometimes async nature.. it seems to depend on the presence of a callback as well as the result of the handler.. does that mean they are also maybe-async?