in reply to RFC: CGI::Application::Plugin::REST
I do have the feeling that the REST_route setup calls are a bit verbose. Would it be possible to come up with a terser interface?
Maybe something like this:
That avoids typing out the obvious for every single runmode/request_method combination.$self->REST_route( widgets => { GET => { MEDIA_TYPES => [...], FUNCTION => [...] }, POST => { ... }, }, some_other_runmode => { GET => { ... }, POST => { ... }, }, );
Another idea is to configure the REST details with attributes on the actual functions. That might look like this:
That might be a bit heavy though, and it may not be too practical. But the obvious benefit is that you keep the REST details close to the function handling the request, and there is minimal redundancy.# nothing in setup() sub get_widget : REST( GET => widgets, TYPES => [ 'application/xhtml+xml', 'text/ht +ml', 'text/plain' ], PARAMS => [ 'product_number' ] ) { # implementation }
Anyway, this is in no way meant to detract from the excellent work you did here. These ideas just popped up on first reading, and I didn't think them through. Take them for what they're worth :-)
|
|---|