Weather checking service. It allows to query weather information based on a user location.
Currently, is only integrated with weatherapi.com
- Set
country
andcity
request params - Send the request
Example:
curl "https://test.website/now?country=Spain&city=Ibiza" -v
< HTTP/1.1 200
< Content-Type: application/json
<
{
"value": {
// Celsius
"c": {
"max": 18,
"min": 13,
"val": 15
},
// Fahrenheit
"f": {
"max": 65,
"min": 60,
"val": 62
}
},
"condition": "partial-rain",
"stale": false,
"updated": "2025-05-06T17:15:00Z"
}
Possible values for the condition
field (see also /weather-images
directory):
blizzard
clear (show 'sunny' or 'night', depends on the times of the day)
clouds
drizzle
fog
freezing-drizzle
freezing-rain
heavy-freezing-drizzle
heavy-freezing-rain
partial-rain
partial-snow
partial-sun
rain
rain-storm
shower
snow
snow-storm
storm
Note
If there was no connection between this and 3d-party services for long time, then stale
flag is set to true
and the last known weather value is returned.
How to build and run:
export MONGO_URI="mongodb+srv://weather:test@mongodb.example.com/?tls=true&authSource=admin&replicaSet=mongodb"
export API_SECRET_KEY="586e596cb3ebe58d4e6913fd5df2"
cd weather
go build
./app
Environment variables and defaults:
API_SECRET_KEY=''
API_URL='https://api.weatherapi.com/v1/forecast.json'
CACHE_TIMEOUT='20m'
HOST_BINDING=':8080'
LOG_MONGO_URI='false'
MONGO_DATABASE='weather'
MONGO_URI=''
TLS_CERT_PATH='tls/cert.pem'
TLS_KEY_PATH='tls/private.key'
TLS_USE='false'
Also available on Docker Hub