Timothy Appnel wrote:
> On 1/3/07, Michael Peters <[EMAIL PROTECTED]> wrote:
> 
>> > Still
>> > I could see someone working this style into an existing application
>> > suite over time. For that I was thinking the ability to check for a
>> > "methodless" runmode could be supported. For instance GET /people
>> > would look for people_GET and if that doesn't exist look for just
>> > people.
>>
>> I'm not sure I like that much magic in the dispatching.
> 
> Isn't "magic" what a framework is about for a developer anyway?

True, but so far Dispatch doesn't do any "try this run mode, if it doesn't exist
try this one" kind of magic. I'd rather not add it unless there's a general
consensus for it.

>> > The HTTP methods are formally uppercased. Most browser will accept it
>> > regardless of case. I like uppercase because it makes it easier to
>> > grok what is part of the REST convention and what's my method name.
>>
>> Yeah, I think I'll just make it a preference.
> 
> what would be the default?

The default would be upper case.

>> That approach won't quite work. URL dispatching is based on the ...
> 
> OK, but I still prefer convention over configuration where this is
> unnecessary.
> 
>>  '/:app/:rm[get]'    => { rm => 'get_stuff' },
>>  '/:app/:rm[post]'   => { rm => 'add_stuff' },
>>  '/:app/:rm[delete]' => { rm => 'delete_stuff' },
> 
> :rm and rm => 'get_stuff'? Did you mean...
> 
> '/:app/stuff[get]'    => { rm => 'get_stuff' },

Yes, I did mean that.

> Perhaps this is premature optimization? Are you sure any developer who
> wants to write a RESTful app wants/needs that level of detail? It just
> seems so much easier, concise and elegant to be able to do...
> 
> '/:app/stuff'    => { },

And you can do exactly that if you set 'auto_rest' to true in your global args.
In fact it becomes dead simple if you're using auto_rest and you want to enable
it for all your modules and run modes:

CGI::Applicaction::Dispatch->dispatch(auto_rest => 1);

Then any url that would match ':app/:rm' would become become App->rm_METHOD.

> ...and then simply create methods like stuff_GET and stuff_POST in my
> module. I don't see why anyone developing an app in a RESTful fashion
> would want to spend the extra effort creating and managing what could
> become a complex dispatch table.

I agree that most of the time you'll want it to work like I've shown above. But
when I was thinking about this feature and how I would use it in an existing
application I was pretty sure I'd need some finer grained controls. Maybe I'm
wrong, but it's a pretty small amount of code to accomplish it.

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to