derks/drest — Issue #6: Add capability to suppress final forward-slash
Author: aalcock
Created: 2012-03-08 07:04:09+00:00
State: open

Currently drest forces all Resource URLs to end with a forward slash (RequestHandler.request() creates the URL using a string format "%s%s/").

Some REST services have Resources at URIs ending with a slash, and some emphatically require no final slash. The above behaviour therefore makes drest incompatible with many REST services.

I would propose something along the lines of setting a flag either on the API itself, or possibly also at Resource level, (let's call this "append_slash") to disable this builtin behaviour. Default behaviour could be to set this true and so preserve current behaviour. Then the following can be implemented:

class RequestHandler(MetaMixin):

def request(self, method, path, params={}, headers={}):

if path == '':
url = self._meta.baseurl
else:
url = "%s%s%s" % (self._meta.baseurl, path, "/" if self._meta.append_slash else "")