Add generic require_method helper, alongside require_post
diff --git a/Allura/allura/lib/decorators.py b/Allura/allura/lib/decorators.py
index 241164a..078eaa4 100644
--- a/Allura/allura/lib/decorators.py
+++ b/Allura/allura/lib/decorators.py
@@ -115,6 +115,20 @@
return func
+def require_method(*methods):
+ """
+ Usage:
+
+ @require_method('GET', 'HEAD')
+ def foo()
+ """
+ def check_methods(func, *args, **kwargs):
+ if request.method not in methods:
+ raise exc.HTTPMethodNotAllowed(headers={'Allow': str(','.join(methods))})
+ return func(*args, **kwargs)
+ return decorator(check_methods)
+
+
@decorator
def reconfirm_auth(func, *args, **kwargs):
'''