pub(crate) fn main()Expand description
Main application entry point.
Initializes the server by:
- Loading environment variables from
.envfile - Establishing database connection pool to PostgreSQL
- Configuring CORS policy for cross-origin requests
- Creating the router with
create_routercontaining all endpoints - Starting HTTP server on port 8001
§Server Configuration
- Binds to
0.0.0.0:8001(all network interfaces) - Allows: GET, POST, PATCH, DELETE methods
- Allows credentials and custom headers
- CORS origin configured from
Env
§State Setup
Creates shared AppState wrapped in Arc and passes to all routes
§Panics
- If environment loading fails
- If database connection fails