Skip to content

Commit

Permalink
[FIX]Add redoc url redirect /docs to /docs/
Browse files Browse the repository at this point in the history
Merge pull request #416 from annuaire-entreprises-data-gouv-fr/fix-endpoint-doc
  • Loading branch information
HAEKADI authored Sep 2, 2024
2 parents 2886b85 + 9c9dcbd commit d4a7c10
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from elasticapm.contrib.starlette import ElasticAPM, make_apm_client
from elasticsearch_dsl import connections
from fastapi import FastAPI, Request
from fastapi.responses import RedirectResponse

from app.config import (
APM_CONFIG,
Expand Down Expand Up @@ -62,6 +63,12 @@ def custom_openapi():
add_exception_handlers(app)


# Redirect /docs to /docs/
@app.get("/docs", include_in_schema=False)
async def docs_redirect():
return RedirectResponse(url="/docs/")


# Catch-all route for 404 errors
@app.api_route("/{path_name:path}", methods=["GET", "POST", "PUT", "DELETE"])
async def catch_all(request: Request, path_name: str):
Expand Down

0 comments on commit d4a7c10

Please sign in to comment.