Skip to content

flaviojmendes/weathergo

Repository files navigation

Weather GO

Logo

Build Status codecov

Simple App that returns the Weather based on the Latitude and Longitude.

Before you start:

It is required to have an ENV Variable named CONFIG_PATH pointing to a YAML file with the following scructure.

Port: :8000       # the port you want
CacheExp: 5       # time in minutes to the cache expiration
CachePurge: 10    # time in minutes to the purge of expired cached weathers
DbFile: path/to/your/weather.db
WhiteListHosts:
  - host1
  - host2
OpenWeatherKeys:  # any number of keys you want
  - key1
  - key2
  - ...

You can find an example of this file here.

And now?

To Get the weather you should do a GET Request to:

HTTP GET http://localhost:8000/weather/{latitude}/{longitude}/{provider}

Example

HTTP GET http://localhost:8000/weather/52.1044634/-9.7957984/OPENWEATHER

Will result in:

{  
   "lat":"52.1044634",
   "lon":"-9.7957984",
   "temp":9.78,
   "location":"Killorglin",
   "humidity":94,
   "created_at":"2018-12-05T21:39:04.769538Z"
}

Getting from DockerHub

docker run -i -p 443:443 -e CONFIG_FILE='/usr/local/config_sample.yml' -v {PATH_TO_YOUR_LOCAL_YML_CONFIG}:/usr/local/config_sample.yml flaviojmendes/weather

About

Simple App written in GO that returns the Weather based on the Latitude and Longitude.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published