Skip to content

Conversation

@anonfedora
Copy link
Contributor

Add Weather API feature

This PR adds a new weather endpoint to our Axum server that fetches current weather data for multiple cities concurrently.

Changes

  • Added /weather endpoint to retrieve weather data for London, Tokyo, and New York
  • Integrated with the WeatherAPI service using environment variables for API key configuration
  • Implemented concurrent API requests using Tokio's join! macro for improved performance
  • Added necessary dependencies: reqwest with JSON feature and serde for serialization
  • Created a shared application state with HTTP client to be reused across requests

Implementation Details

  • Created a new weather.rs module with the weather endpoint handler
  • Added AppState struct to hold the HTTP client and API key
  • Modified server setup to initialize and pass application state to routes
  • Set up proper environment variable handling for base URL and API key

Screenshot_20250317_170636
Screenshot_20250317_170701

Note: Requires WEATHER_API_KEY environment variable to be set before running the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant