'Decorator for versioning API methods.
Add the decorator to any method which takes a request object
as the first parameter and belongs to a class which inherits from
wsgi.Controller.
:param min_ver: string representing minimum version
:param max_ver: optional string representing maximum version'

@classmethod
def api_version(cls, min_ver, max_ver=None, experimental=False):

    def decorator(f):
        obj_min_ver = api_version.APIVersionRequest(min_ver)
        if max_ver:
            obj_max_ver = api_version.APIVersionRequest(max_ver)
        else:
            obj_max_ver = api_version.APIVersionRequest()
        func_name = f.__name__
        new_func = versioned_method.VersionedMethod(func_name, obj_min_ver, obj_max_ver, experimental, f)
        func_dict = getattr(cls, VER_METHOD_ATTR, {})
        if (not func_dict):
            setattr(cls, VER_METHOD_ATTR, func_dict)
        func_list = func_dict.get(func_name, [])
        if (not func_list):
            func_dict[func_name] = func_list
        func_list.append(new_func)
        func_list.sort(reverse=True)
        f.api_version = cls.api_version
        return f
    return decorator
