def item_endpoint(**lookup): """ Item endpoint handler :param url: the url that led here :param lookup: the query .. versionchanged:: 0.1.1 Relying on request.path for determining the current endpoint url. .. versionchanged:: 0.1.0 Support for PUT method. .. versionchanged:: 0.0.7 Using 'utils.request_method' helper function now. .. versionchanged:: 0.0.6 Support for HEAD requests """ k = request.path.rstrip('/').rfind('/') resource = config.RESOURCES[request.path[:k]] response = None method = request_method() if method in ('GET', 'HEAD'): response = getitem(resource, **lookup) elif method == 'PATCH': response = patch(resource, **lookup) elif method == 'PUT': response = put(resource, **lookup) elif method == 'DELETE': response = delete(resource, **lookup) elif method == 'OPTIONS': send_response(resource, response) else: abort(405) return send_response(resource, response)
def item_endpoint(url, **lookup): """ Item endpoint handler :param url: the url that led here :param lookup: the query .. versionchanged:: 0.1.0 Support for PUT method. .. versionchanged:: 0.0.7 Using 'utils.request_method' helper function now. .. versionchanged:: 0.0.6 Support for HEAD requests """ resource = config.RESOURCES[url] response = None method = request_method() if method in ('GET', 'HEAD'): response = getitem(resource, **lookup) elif method == 'PATCH': response = patch(resource, **lookup) elif method == 'PUT': response = put(resource, **lookup) elif method == 'DELETE': response = delete(resource, **lookup) elif method == 'OPTIONS': send_response(resource, response) else: abort(405) return send_response(resource, response)
def item_endpoint(url, **lookup): """ Item endpoint handler :param url: the url that led here :param lookup: the query .. versionchanged:: 0.0.7 Using 'utils.request_method' helper function now. .. versionchanged:: 0.0.6 Support for HEAD requests """ resource = config.RESOURCES[url] response = None method = request_method() if method in ('GET', 'HEAD'): response = getitem(resource, **lookup) elif method == 'PATCH': response = patch(resource, **lookup) elif method == 'DELETE': response = delete(resource, **lookup) elif method == 'OPTIONS': send_response(resource, response) else: abort(405) return send_response(resource, response)
def item_endpoint(**lookup): """ Item endpoint handler :param url: the url that led here :param lookup: sub resource query .. versionchanged:: 0.2 Support for sub-resources. Relying on request.endpoint to retrieve the resource being consumed. .. versionchanged:: 0.1.1 Relying on request.path for determining the current endpoint url. .. versionchanged:: 0.1.0 Support for PUT method. .. versionchanged:: 0.0.7 Using 'utils.request_method' helper function now. .. versionchanged:: 0.0.6 Support for HEAD requests """ resource = _resource() response = None method = request.method if method in ("GET", "HEAD"): response = getitem(resource, **lookup) elif method == "PATCH": response = patch(resource, **lookup) elif method == "PUT": response = put(resource, **lookup) elif method == "DELETE": response = deleteitem(resource, **lookup) elif method == "OPTIONS": send_response(resource, response) else: abort(405) return send_response(resource, response)
def item_endpoint(**lookup): """ Item endpoint handler :param url: the url that led here :param lookup: sub resource query .. versionchanged:: 0.2 Support for sub-resources. Relying on request.endpoint to retrieve the resource being consumed. .. versionchanged:: 0.1.1 Relying on request.path for determining the current endpoint url. .. versionchanged:: 0.1.0 Support for PUT method. .. versionchanged:: 0.0.7 Using 'utils.request_method' helper function now. .. versionchanged:: 0.0.6 Support for HEAD requests """ resource = _resource() response = None method = request_method() if method in ('GET', 'HEAD'): response = getitem(resource, **lookup) elif method == 'PATCH': response = patch(resource, **lookup) elif method == 'PUT': response = put(resource, **lookup) elif method == 'DELETE': response = deleteitem(resource, **lookup) elif method == 'OPTIONS': send_response(resource, response) else: abort(405) return send_response(resource, response)