Esempio n. 1
0
func main() {
	users, _ := models.GetUser()
	fmt.Println(users)

	// initialize router
	rtr := mux.NewRouter()
	http.Handle("/", rtr)

	// routes
	rtr.HandleFunc("/hello/{name}", ctls.IndexHandler)
	rtr.HandleFunc("/user", ctls.UserHandler)

	// some server feedback
	log.Println("Listening...")
	http.ListenAndServe(":8000", nil)
}
Esempio n. 2
0
func UserHandler(w http.ResponseWriter, r *http.Request) {
	users, _ := models.GetUser()
	usersJson, _ := json.Marshal(users)
	w.Write(usersJson)
}