Skip to content

Remove inline root, health, and echo routes#11

Merged
goldlabelapps merged 3 commits intomasterfrom
staging
Mar 19, 2026
Merged

Remove inline root, health, and echo routes#11
goldlabelapps merged 3 commits intomasterfrom
staging

Conversation

@goldlabelapps
Copy link
Owner

Delete the local implementations of '/', '/health', and '/echo' from app/api/routes.py. These handlers were redundant after including root_router, health_router, and echo_router at the top of the file; removing them centralizes route definitions and eliminates the duplicate DB cursor and local Echo request/response logic.

Delete the local implementations of '/', '/health', and '/echo' from app/api/routes.py. These handlers were redundant after including root_router, health_router, and echo_router at the top of the file; removing them centralizes route definitions and eliminates the duplicate DB cursor and local Echo request/response logic.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the inline implementations of the /, /health, and /echo endpoints from app/api/routes.py, relying instead on the already-included root_router, health_router, and echo_router to centralize route definitions and avoid duplication.

Changes:

  • Deleted the local GET /, GET /health, and POST /echo handlers from app/api/routes.py.
  • Kept only the router composition via include_router(...) for the three endpoint routers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 21 to 23
router.include_router(root_router)
router.include_router(health_router)
router.include_router(echo_router)
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the inline GET / handler changes runtime behavior to the implementation in app/api/root.py, which differs from the deleted one: it opens a new psycopg2 connection directly (bypassing get_db_connection's guaranteed cleanup), doesn’t close the cursor/connection in a finally, and casts price to float without a None-check (the removed handler returned None when row[3] is null and stringified non-null prices). To avoid a behavior regression and potential connection leaks, update the centralized root router to use the existing get_db_connection dependency and preserve the previous response shape/type handling (including safe cleanup on errors).

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment on lines 21 to 23
router.include_router(root_router)
router.include_router(health_router)
router.include_router(echo_router)
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After deleting the local route handlers, this module now appears to only build an APIRouter and include root_router, health_router, and echo_router. The remaining imports (__version__, os, time, psycopg2, load_dotenv, Depends, get_db_connection, EchoRequest, EchoResponse) are unused and may fail linting/CI; please remove them (and any now-unnecessary side-effect imports) to keep the module minimal.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI commented Mar 19, 2026

@goldlabelapps I've opened a new pull request, #12, to work on those changes. Once the pull request is ready, I'll request review from you.

[WIP] [WIP] Address feedback on removing inline root, health, and echo routes
@goldlabelapps goldlabelapps merged commit ea52043 into master Mar 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants