Skip to content
Snippets Groups Projects
Commit 61af02a0 authored by DAVID Axel's avatar DAVID Axel
Browse files

refactor: :lipstick: Prepare the app before the v2

parent 21acfd6b
No related branches found
No related tags found
No related merge requests found
...@@ -16,14 +16,13 @@ ...@@ -16,14 +16,13 @@
"""Create the application Vigenere-API.""" """Create the application Vigenere-API."""
from blacksheep import Application from blacksheep import Application, Response
from blacksheep import Response
from blacksheep.server.env import is_development from blacksheep.server.env import is_development
from blacksheep.server.responses import redirect from blacksheep.server.responses import redirect
from .v1.controllers import CaesarController from vigenere_api.version import get_version
from .v1.openapi_docs import docs from .v1.controllers import CaesarController as V1CaesarController
from .v1.openapi_docs import docs as v1_docs
application = Application() application = Application()
application.debug = False application.debug = False
...@@ -39,13 +38,15 @@ if is_development(): # pragma: no cover ...@@ -39,13 +38,15 @@ if is_development(): # pragma: no cover
application.debug = True application.debug = True
application.show_error_details = True application.show_error_details = True
application.register_controllers([CaesarController]) application.register_controllers([V1CaesarController])
docs.bind_app(application) v1_docs.bind_app(application)
get = application.router.get get = application.router.get
version = get_version()
@docs(ignored=True) @v1_docs(ignored=True)
@get() @get()
async def index() -> Response: async def index() -> Response:
""" """
...@@ -58,4 +59,20 @@ async def index() -> Response: ...@@ -58,4 +59,20 @@ async def index() -> Response:
redirect redirect
Response Response
""" """
return redirect("/api/v1") return redirect(f"/api/v{version.major}")
def __fallback() -> str:
"""
Process all requests to bad routes.
Returns
-------
error_text
str
"""
return "OOPS! Nothing was found here!"
application.router.fallback = __fallback
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Vigenere-API +
# Copyright (C) 2023 Axel DAVID +
# +
# This program is free software: you can redistribute it and/or modify it under +
# the terms of the GNU General Public License as published by the Free Software +
# Foundation, either version 3 of the License, or (at your option) any later version. +
# +
# This program is distributed in the hope that it will be useful, but WITHOUT ANY +
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +
# +
# You should have received a copy of the GNU General Public License along with +
# this program. If not, see <https://www.gnu.org/licenses/>. +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"""All OpenAPI docs for each controller."""
from .caesar import post_caesar_cipher_docs
from .caesar import post_caesar_decipher_docs
__all__ = ["post_caesar_cipher_docs", "post_caesar_decipher_docs"]
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Vigenere-API +
# Copyright (C) 2023 Axel DAVID +
# +
# This program is free software: you can redistribute it and/or modify it under +
# the terms of the GNU General Public License as published by the Free Software +
# Foundation, either version 3 of the License, or (at your option) any later version. +
# +
# This program is distributed in the hope that it will be useful, but WITHOUT ANY +
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +
# +
# You should have received a copy of the GNU General Public License along with +
# this program. If not, see <https://www.gnu.org/licenses/>. +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"""The vigenere controller's documentation."""
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Vigenere-API +
# Copyright (C) 2023 Axel DAVID +
# +
# This program is free software: you can redistribute it and/or modify it under +
# the terms of the GNU General Public License as published by the Free Software +
# Foundation, either version 3 of the License, or (at your option) any later version. +
# +
# This program is distributed in the hope that it will be useful, but WITHOUT ANY +
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +
# +
# You should have received a copy of the GNU General Public License along with +
# this program. If not, see <https://www.gnu.org/licenses/>. +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"""The vigenere controller."""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment