Skip to content

joyrexus/weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather Service Tutorial

What's this? Just working through Peter Bourgon's Go tutorial, How I Start, wherein he walks you through setting up a concurrent, REST-style backend server for aggregating weather data from various weather service APIs using only the Go standard library. It's a nice intro to Go-based web services.

cloud-pic

See json-samples for samples of the JSON-encoded data returned by the OpenWeatherMap and Weather Underground APIs.

Note that the Weather Underground API requires an API key. With KEY in hand, try ...

curl http://api.wunderground.com/api/KEY/conditions/q/chicago.json

You can test the OpenWeatherMap API with ...

curl http://api.openweathermap.org/data/2.5/weather?q=Chicago

Setup

Install the weather package with go get -u github.com/joyrexus/weather/.... This will also install the wx and wxserve commands.

Then, be sure to set the WUNDERGROUND_API_KEY environment variable to reflect your Weather Underground API key:

export WUNDERGROUND_API_KEY=your_api_key

If $GOPATH/bin is in your PATH ...

$ wx chicago
35.5

$ wx nashville
65.1

... or run wxserve to start the demo web service and check the following urls in your browser:

http://localhost:8080/weather/chicago

http://localhost:8080/weather/nashville

To Do

Query the services concurrently.

About

⛅ A simple web service demo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages