func main() {
	Data[1] = "a"
	Data[2] = "b"
	Data[3] = "c"
	Data[4] = "d"
	Data[5] = "e"
	Data[6] = "f"
	Data[7] = "g"
	Data[8] = "h"
	Data[9] = "i"
	Data[10] = "j"

	for _, each := range Instances {
		Cache[g_p(each)] = each
	}

	for k, _ := range Data {
		Cache[g_p(strconv.Itoa(k))] = strconv.Itoa(k)
	}

	for k, _ := range Cache {
		S_keys = append(S_keys, k)
	}

	sort.Strings(S_keys)
	mux := httprouter.New()
	mux.PUT("/keys/:key/:value", put_h)
	mux.GET("/keys/:key", h_get)
	server := http.Server{
		Addr:    "0.0.0.0:8187",
		Handler: mux,
	}
	server.ListenAndServe()
}
Exemple #2
0
func main() {
	Data[1] = "a"
	Data[2] = "b"
	Data[3] = "c"
	Data[4] = "d"
	Data[5] = "e"
	Data[6] = "f"
	Data[7] = "g"
	Data[8] = "h"
	Data[9] = "i"
	Data[10] = "j"

	for _, each := range ServerArr {
		HashMap[getHash(each)] = each
	}

	for k, _ := range Data {
		HashMap[getHash(strconv.Itoa(k))] = strconv.Itoa(k)
	}

	for k, _ := range HashMap {
		SortedHashMapKeys = append(SortedHashMapKeys, k)
	}

	sort.Strings(SortedHashMapKeys)
	mux := httprouter.New()
	mux.PUT("/keys/:key/:value", handlePutRequests)
	mux.GET("/keys/:key", handleGetRequests)
	server := http.Server{
		Addr:    "0.0.0.0:8000",
		Handler: mux,
	}
	server.ListenAndServe()
}
Exemple #3
0
func main() {
	// Instantiate a new router
	r := httprouter.New()

	r.POST("/hello", GreetUser)

	http.ListenAndServe("localhost:8080", r)
}
func main() {
	r := httprouter.New()

	r.POST("/locations", CreateNewLocation)
	r.GET("/locations/:idno", GetLocation)
	r.PUT("/locations/:idno", UpdateLocation)
	r.DELETE("/locations/:idno", DeleteLocation)
	http.ListenAndServe("localhost:5000", r)
}
func main() {
	mux := httprouter.New()
	mux.POST("/hello", hello)
	server := http.Server{
		Addr:    "0.0.0.0:8080",
		Handler: mux,
	}
	server.ListenAndServe()
}
func main() {
	r := httprouter.New()

	r.POST("/trips", PlanTrip)
	r.GET("/trips/:tripid", GetTripDetails)
	r.PUT("/trips/:tripid/request", RequestACar)

	http.ListenAndServe("localhost:6000", r)
}
func main() {
	mux := httprouter.New()
	mux.PUT("/keys/:key/:value", upd_K)
	mux.GET("/keys/:key", get_K)
	mux.GET("/keys", getall_K)
	server := http.Server{
		Addr:    "0.0.0.0:3001",
		Handler: mux,
	}
	server.ListenAndServe()
}
func main() {
	mux := httprouter.New()
	mux.PUT("/keys/:key/:value", updateMap)
	mux.GET("/keys/:key", getMapData)
	mux.GET("/keys", getAllMapData)
	server := http.Server{
		Addr:    "0.0.0.0:3000",
		Handler: mux,
	}
	server.ListenAndServe()
}
func main() {
	router := httprouter.New()
	router.POST("/locations", createLocation)
	router.GET("/locations/:location_id", getLocation)
	router.PUT("/locations/:location_id", putLocation)
	router.DELETE("/locations/:location_id", deleteLocation)
	server := http.Server{
		Addr:    "0.0.0.0:8080",
		Handler: router,
	}
	server.ListenAndServe()
}
func main() {
	i1 = 0
	i2 = 0
	i3 = 0
	mux := httprouter.New()
	mux.GET("/keys", GetAllKeys)
	mux.GET("/keys/:key_id", GetKey)
	mux.PUT("/keys/:key_id/:value", PutKeys)
	go http.ListenAndServe(":3000", mux)
	go http.ListenAndServe(":3001", mux)
	go http.ListenAndServe(":3002", mux)
	select {}
}
func main() {
	mux := httprouter.New()
	mux.GET("/locations/:locationID", getLocation)
	mux.POST("/locations", addLocation)
	mux.PUT("/locations/:locationID", updateLocation)
	mux.DELETE("/locations/:locationID", deleteLocation)
	server := http.Server{
		Addr:    "0.0.0.0:8080",
		Handler: mux,
	}
	connectMongo()
	server.ListenAndServe()
}
func main() {
	// Instantiate a new router
	router := httprouter.New()

	// Get a controller instance
	mycontroller := NewMyController()

	// Add handlers
	router.GET("/keys/:id", mycontroller.GetKey)
	router.GET("/keys", mycontroller.GetAllKeys)
	router.PUT("/keys/:id/:value", mycontroller.PutKey)

	// Expose the server at port 3000
	http.ListenAndServe(":3000", router)
}
func main() {
	router := httprouter.New()
	router.POST("/locations", createLocation)
	router.GET("/locations/:location_id", getLocation)
	router.PUT("/locations/:location_id", putLocation)
	router.DELETE("/locations/:location_id", deleteLocation)
	router.POST("/trips", createTrip)
	router.GET("/trips/:trip_id", getTrip)
	router.PUT("/trips/:trip_id/requestUber", updateTrip)
	server := http.Server{
		Addr:    "0.0.0.0:8000",
		Handler: router,
	}
	server.ListenAndServe()
}
func main() {
	mux := httprouter.New()
	mux.GET("/locations/:locationID", getLocation)
	mux.POST("/locations", addLocation)
	mux.PUT("/locations/:locationID", updateLocation)
	mux.DELETE("/locations/:locationID", deleteLocation)
	mux.GET("/trips/:trip_id", GetTrip)
	mux.POST("/trips", AddTrip)
	mux.PUT("/trips/:trip_id/request", UpdateTrip)
	server := http.Server{
		Addr:    "0.0.0.0:8080",
		Handler: mux,
	}
	connectMongo()
	server.ListenAndServe()
}