Function test_routes

Source
pub fn test_routes(app_state: AppState) -> Router<AppState>
Expand description

Registers the test routes on a Router<AppState>.

Why mount here (not in main):

  • Keeps env-conditional test endpoints colocated with handlers and types.
  • Avoids changing the router type in main (prevents trait-bound surprises).
  • Improves discoverability and maintenance of the test API surface.

§Available routes

  • POST /api/test/users
    Create or update a test user. Idempotent — if username exists, updates instead. Always returns the id so it can be deleted in teardown.
  • GET /api/test/users?username=NAME
    Fetch a test user by their username.
  • DELETE /api/test/users/{id}
    Delete a test user by numeric ID.