core ModuleThe Core Module provides essential infrastructure and non-domain-specific capabilities for the application. It includes:
robots.txt, sitemap.xml)This module is used across all feature modules and initialized via main.rs.
src/
├── core/
│ ├── api/
│ │ ├── main.rs # Root-level endpoint handlers (e.g. GET `/`)
│ ├── error.rs # Global AppError + IntoResponse
│ ├── rate_limiter.rs # Shared Redis-based rate limiting
│ ├── shared.rs # Static sitemap/robots serving
│ └── middleware/
│ └── session_extractor.rs # Extracts WebUserSession from cookies
| Method | Path | Description |
|---|---|---|
| GET | /api/ |
Core API base info (get_index) |
| GET | /sitemap.xml |
Sitemap XML (serve_sitemap) |
| GET | /robots.txt |
Robots.txt (serve_robots) |
No entity models defined in this module.
This module operates independently of application-specific databases and does not contain any SeaORM schema logic.
No request structs defined
The core module provides passive GET-based endpoints and middleware support. It does not process JSON body inputs.
get_index:
Json(json!({
"message": "Welcome to the Magic Toybox API",
"status": "ok",
"version": "1.0"
}))
get_index()serve_sitemap():
Returns application/xml-formatted sitemap using base URL from .env.
serve_robots():
Returns text/plain robots directive, linking to sitemap.
get_index
serve_sitemap
application/xmlserve_robots
robots.txttext/plainAppError enum
NotFoundConflict(String)BadRequest(String)InternalServerErrorimpl IntoResponse for AppError
{
"error": "Not found",
"status": 404
}
impl From<DbErr> for AppError
InternalServerErroris_rate_limited(conn, key, cooldown_secs)
WebUserSession struct
user_id extracted from a session cookieimpl FromRequestParts for WebUserSession
"session"WebUserSession if valid; otherwise returns 401AppError to include validation and auth variants (e.g., Unauthorized, Forbidden)AppError optionally log stack traces or error metadata in non-productionrate_limiter behavior with mocked Redis connection/api/openapi.json