Created
May 23, 2015 00:39
-
-
Save zgramana/aa188d067e10a91a5d39 to your computer and use it in GitHub Desktop.
Gets the changes feed and prints the results.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "io/ioutil" | |
import "net/http" | |
func main() { | |
// Changes Feed (GET http://127.0.0.1:4984/db/_changes?feed=longpoll&limit=50&heartbeat=300000&style=all_docs&since=1&include_docs=false) | |
// Create client | |
client := &http.Client{} | |
// Create request | |
req, err := http.NewRequest("GET", "http://127.0.0.1:4984/db/_changes?feed=longpoll&limit=50&heartbeat=300000&style=all_docs&since=1&include_docs=false", nil) | |
req.Header.Add("Accept-Encoding", `gzip/deflate`) | |
parseFormErr := req.ParseForm() | |
if parseFormErr != nil { | |
fmt.Println(parseFormErr) | |
} | |
// Fetch Request | |
resp, err := client.Do(req) | |
if err != nil { | |
fmt.Println("Failure : ", err) | |
} | |
// Read Response Body | |
respBody, _ := ioutil.ReadAll(resp.Body) | |
// Display Results | |
fmt.Println("response Status : ", resp.Status) | |
fmt.Println("response Headers : ", resp.Header) | |
fmt.Println("response Body : ", string(respBody)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment