Implement task API with input validation; implement error handling; refactoring
This commit is contained in:
parent
19d264a03b
commit
50aff05614
24 changed files with 612 additions and 131 deletions
30
tofu_api/api/tasks/task_blueprint.py
Normal file
30
tofu_api/api/tasks/task_blueprint.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from tofu_api.common.rest import BaseBlueprint
|
||||
from .task_views import TaskCollectionView, TaskItemView
|
||||
|
||||
|
||||
class TaskBlueprint(BaseBlueprint):
|
||||
"""
|
||||
Blueprint for the tasks REST API.
|
||||
"""
|
||||
|
||||
# Blueprint settings
|
||||
name = 'rest_api_tasks'
|
||||
import_name = __name__
|
||||
url_prefix = '/tasks'
|
||||
|
||||
def init_blueprint(self) -> None:
|
||||
"""
|
||||
Register URL rules.
|
||||
"""
|
||||
task_handler = self.app.dependencies.get_task_handler()
|
||||
|
||||
self.add_url_rule(
|
||||
'',
|
||||
view_func=TaskCollectionView.as_view(task_handler=task_handler),
|
||||
methods=['GET', 'POST'],
|
||||
)
|
||||
self.add_url_rule(
|
||||
'/<int:task_id>',
|
||||
view_func=TaskItemView.as_view(task_handler=task_handler),
|
||||
methods=['GET', 'PATCH', 'DELETE'],
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue