aquarat / google-api-go-client

Automatically exported from code.google.com/p/google-api-go-client
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Support for push notifications #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
API Push Notifications were recently announced and demoed at I/O 
(http://www.youtube.com/watch?v=NlZZghBnfdM)

It would be great to have some of these common parts done by Go library code, 
so a developer could skip having to rewrite the protocol code each time.

If the Discovery document exposes the requisite information, Go code could be 
generated to allow developers to write something like:

svc.Playlists.Watch(playlistId).Do()
svc.Playlists.HandleNotification("/notifications", func(w http.ResponseWriter, 
r *http.Request, p youtube.Playlist, s common.StateChange) {
    // Do something with the updated playlist
    // stateChange is an enum describing whether it's an insertion, update, or deletion operation
})

This would register a http.HandleFunc that parses the request headers to 
determine the StateChange being described, and decode the JSON body into the 
Playlist, and pass it to the func.

I'm not sure if Discovery documents expose enough information for this to be 
possible, or if this is a good API surface, but it's worth looking into at 
least.

Original issue reported on code.google.com by imjas...@gmail.com on 22 May 2013 at 3:25