Skip to content

Commit

Permalink
docs: add redirect /docs to /docs/
Browse files Browse the repository at this point in the history
  • Loading branch information
HAEKADI committed Sep 2, 2024
1 parent e8bb9d8 commit 9c9dcbd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion 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 @@ -32,7 +33,7 @@
title="API Recherche d'entreprises",
version="1.0.0",
docs_url=None,
redoc_url="/docs",
redoc_url="/docs/",
)


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 9c9dcbd

Please sign in to comment.