Skip to content

Commit

Permalink
Add headers_only query string parsing to Item resource
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Jun 21, 2021
1 parent 51bddfa commit fb8b46e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/webqueue2api/api/resources/item.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from flask import request
from flask_restful import Resource
from flask_jwt_extended import jwt_required
# To avoid naming conflicts
Expand All @@ -11,6 +12,7 @@ def get(self, queue: str, number: int) -> tuple:
Return Codes:
200 (OK): On success.
404 (Not Found): When an Item does not exist.
Example:
/api/ce/100 returns:
Expand Down Expand Up @@ -38,7 +40,9 @@ def get(self, queue: str, number: int) -> tuple:
Returns:
tuple: Item as JSON and HTTP response code.
"""
headers_only = True if request.args.get("headers_only") == "True" else False

try:
return (_Item(queue, number).to_json(), 200)
return (_Item(queue, number, headers_only=headers_only).to_json(), 200)
except ItemDoesNotExistError:
return ({"message": f"Item {queue}{number} not found."}, 404)

0 comments on commit fb8b46e

Please sign in to comment.