events

package
v0.0.0-...-941a20e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

README

Step 3: adding weather with openweathermap.org

So far, we have an application that is capable of storing events submitted through a web form, and display them back into the web page.

Now we're going to add some cool functionality by retrieving the weather for the location where the event is taking place. To do so we need to fetch information from an external API, and we will use open openweathermap.org.

You need to sign up to https://openweathermap.org to obtain an API key and replace the value of WEATHER_API_KEY in the app.yaml file.

Then you'll implement the call to the API, preparing the request, decoding the response, and adding the resulting weather to the events.

This will cause one API call per event per request, which is incredibly wasteful. But don't worry we'll fix that later, for now come back to the instructions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Date        time.Time `json:"date"`
	Location    string    `json:"location"`
	Weather     *Weather  `json:"weather" datastore:"-"`
}

Event contains the information related to an event.

type Weather

type Weather struct {
	Description string `json:"description"`
	Icon        string `json:"icon"`
}

Weather contains the description and icon for a weather condition.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL