Skip to content

Instantly share code, notes, and snippets.

@bohde
Created February 20, 2012 22:38
Show Gist options
  • Save bohde/1871999 to your computer and use it in GitHub Desktop.
Save bohde/1871999 to your computer and use it in GitHub Desktop.
_SUPPORTED_TRANSFORMS = set(['PUT', 'DELETE', 'PATCH'])
_MIDDLEWARE_KEY = 'real_method'
class HttpMethodsMiddleware(object):
def process_request(self, request):
if request.GET and request.GET.has_key(_MIDDLEWARE_KEY):
new_method = request.GET[_MIDDLEWARE_KEY].upper()
if new_method in _SUPPORTED_TRANSFORMS:
request.method = new_method
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment