The Weather API application provides weather information based on latitude and longitude. It is designed to demo a weather forecasts API and related data in a simple, RESTful manner.
- Retrieve weather data using geographical coordinates.
- Provides temperature, weather conditions, and a description of how the temperature feels.
- Supports CRUD operations for weather data management.
- Language: Go
- Framework: Gorilla Mux for routing
- Middleware: Custom middleware for JSON responses, logging, and metrics
- GET /api/v1/weather/{latitude},{longitude}: Retrieve weather information for a specific location.
- PUT /api/v1/weather: Update weather data (not fully implemented here).
- POST /api/v1/weather: Create new weather data (not fully implemented here).
- DELETE /api/v1/weather: Delete weather data (not fully implemented here).
Name | Default Value | Description |
---|---|---|
SERVER_ADDRESS | :8080 | Specifies the server address and port to bind the application to |
- Go 1.22 installed on your machine.
- Docker installed for containerization.
- Clone the repository:
git clone https://github.com/sooonmitch/weather-api-demo
cd weather-api-demo
- Run the application:
go run ./
- Access the API: Use
curl
or a tool like Postman to interact with the API
curl "http://localhost:8080/api/v1/weather/40,74"
- Build the Docker image:
docker build -t app .
- Run the Docker container:
docker run -p 8080:8080 -e SERVER_ADDRESS=0.0.0.0:8080 app
- Test the API: Again, use curl or Postman:
curl "http://localhost:8080/api/v1/weather/40,74"
Set the release tag:
git tag -a v1.0.0 -m "<Release Message>"
Push the release tag
git push origin v1.0.0
Run gorelease
goreleaser release
Run unit tests to ensure the application works as expected:
go test ./...
- This is a demo, it will lack features and comforts
- Modify the SERVER_ADDRESS environment variable as needed.
- Ensure that ports used are not conflicting with other applications.