deleteman / vatican

Micro-framework designed to create REST APIs with minor effort
98 stars 6 forks source link

method validator for handlers #11

Closed smart--petea closed 10 years ago

smart--petea commented 10 years ago

I generate a handler file. I didn't any change in it. I run the project. All it's ok, rather the method for each action is by default equal with ??.

Maybe it is needed to validate the method. For ex:

_.contains(['GET', 'POST', 'DELETE', 'PUT'], method.trim().toUpperCase())

And if not to log this as error.

deleteman commented 10 years ago

@smart--petea checkout branch https://github.com/deleteman/vatican/tree/v1.3 I've added a new syntax for the generator, that will allow you to specify the method to use (per ticket https://github.com/deleteman/vatican/issues/10) that should take care of writing the correct method, instead of "??"

smart--petea commented 10 years ago

Will be there support for 'delete' method?

deleteman commented 10 years ago

Yes of course, why do you ask?

smart--petea commented 10 years ago

the regexp (from handlerParser.js)

  var regExp = /@endpoint ?\((url:.+) (method: (?:get|put|post)) ?(name:.+)?\).*\n(.*)\(/gim;

only support three method: get, put and post

deleteman commented 10 years ago

Oh wow, I missed that one! Thanks for pointing it out @smart--petea !! I've added the missing method in this commit (for branch 1.3): https://github.com/deleteman/vatican/commit/4a4fdafed39266d997984b2fb24143e79ccef702

Thanks again!