Categories
Go

Fetching venues from Foursquare using Go

package main

import (
    "fmt"
    "github.com/codegangsta/negroni"
    "github.com/gorilla/mux"
    "encoding/json"
    "net/http"
    "github.com/elbuo8/4square-venues"
)


func main() {
    mux := mux.NewRouter()
    mux.HandleFunc("/", IndexHandler).Methods("GET")
    mux.HandleFunc("/venues/{query}", FoursquareHandler).Methods("GET")
    n := negroni.Classic()
    n.UseHandler(mux)
    n.Run(":3000")
}


func IndexHandler(w http.ResponseWriter, r *http.Request){
	p := "Page"
	fmt.Fprintf(w, "Home %s\n", p)
}


func FoursquareHandler(w http.ResponseWriter, r *http.Request){
    vars := mux.Vars(r)
    category := vars["query"]
    fs := fsvenues.NewFSVenuesClient("FOURSQUARE_ID", "FOURSQUARE_SECRET")
    params := make(map[string]string)
    params["ll"] = "32.7,-96.8"
    params["limit"] = "5"
    params["query"] = category

    if v, e := fs.GetVenues(params); e == nil {
        data, _ := json.Marshal(v)
        w.Header().Set("Content-Type", "application/json")
        w.Write(data)
    } else {
        fmt.Println(e)
    }
}

Third party packages used:

Normal Erection ConditionsA browse this link cheap 25mg viagra normal erection is a complicated multi-system dysfunction. L-Arginine – It is an amino acid cheap cialis in canada that your body requires for the production of healthy sperm. The therapy facilitates one’s thinking process to be more healthy and natural way by this medicine. tadalafil tablets in india http://raindogscine.com/?attachment_id=44 If you are looking tadalafil side effects for a renowned hypnotherapist and career coach in Beverly Hills, then you should immediately schedule an initial consultation with Beatrix Wagner at Hypnosis-LA.