Exemplo n.º 1
0
func main() {
	api := apidb.Open()
	defer api.Close()

	http.HandleFunc("/products/", productsHandler(api))
	http.ListenAndServe(":8000", nil)
}
Exemplo n.º 2
0
func main() {
	api := apidb.Open()
	defer api.Close()

	r := mux.NewRouter()
	r.HandleFunc("/stores/", storesHandler(api))
	r.HandleFunc("/purchases/{storeId}/{productId}", purchasesHandler(api))
	r.HandleFunc("/products/", productsHandler(api))
	r.HandleFunc("/receipt_uploads/", receiptUploadsHandler(api))
	r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "../ui/build/index.html")
	})
	http.ListenAndServe(":8000", r)
}