Web Dev Custom Method

Is there a way to add custom methods to the Web Dev module. For instance, I want a python resource to have a HTTP method called RESET. Then in my HTTP Method drop down I would have a selection for doReset.

If that is not possible is there other suggestions about how to best go about doing something like this that will scale? For example, using POST but in the request include a key for the method/action trying to be performed on the resource.

HTTP method are standards

Do this. Going outside the HTTP specification (the allowed methods are listed in the spec, with no indication that users can make up their own) is begging for trouble, especially when your traffic passes through a proxy somewhere.

So, are you both in favor of using a post and embedding the action/method name in the post data?

How about this way of doing it? Can this be used somehow in WebDev?

POST /files/a/long/file/name:undelete

where undelete is my custom method. How would I parse this URL path and get this custom method.

General conventions around REST/web APIs suggest the URL indicating the "noun" and the data in the POST payload containing the associated context. You can choose any serialization method you wish, though JSON is common and well supported in Webdev.

Looks like I can use the remainingPath request parameter to get any trailing resource, but the :undelete does not seem to be in there. I guess I will have to go with embedding the method/action in the post data.

If you want to pass a parameter in the URL, use the standard mechanism: path/to/endpoint?paramName=paramValue.

Again, well supported by Webdev, HTTP clients, etc.

1 Like