Esempio n. 1
0
func main() {
	r := httprouter.New()

	uc := controllers.NewUserController(getSession())

	r.GET("/user/:id", uc.GetUser)

	r.POST("/user", uc.CreateUser)

	r.DELETE("/user/:id", uc.RemoveUser)

	http.ListenAndServe("localhost:3000", r)
}
func main() {
	// Instantiate a new router
	r := httprouter.New()
	// Get a UserController instance
	uc := controllers.NewUserController(getSession())
	// Get a user resource
	r.GET("/user/:id", uc.GetUser)
	// Create a new user
	r.POST("/user", uc.CreateUser)
	// Remove an existing user
	r.DELETE("/user/:id", uc.RemoveUser)
	// Fire up the server
	http.ListenAndServe("localhost:3000", r)
}
Esempio n. 3
0
func main() {
	// Instantiate a new router
	router := httprouter.New()

	// Get a controller instance
	controller := controllers.NewUserController()

	// Add handlers
	router.GET("/locations/:id", controller.GetLocation)
	router.POST("/locations", controller.CreateLocation)
	router.PUT("/locations/:id", controller.UpdateLocation)
	router.DELETE("/locations/:id", controller.DeleteLocation)

	// Expose the server at port 3000
	http.ListenAndServe("localhost:3000", router)
}