func main() { fmt.Println("Server is listening on 8080!") userController := controllers.NewUserController(getSession()) mux := httprouter.New() //Create new location mux.POST("/locations", userController.CreateLocation) //Get the location mux.GET("/locations/:locationId", userController.GetLocation) //Update the location mux.PUT("/locations/:locationId", userController.UpdateLocation) //Delete the location mux.DELETE("/locations/:locationId", userController.DeleteLocation) server := http.Server{ Addr: "0.0.0.0:8080", Handler: mux, } server.ListenAndServe() }
func main() { mux := httprouter.New() // Get a UserController instance uc := controllers.NewUserController(getSession()) mux.GET("/locations/:id", uc.GetLocations) mux.POST("/locations/", uc.CreateLocations) mux.DELETE("/locations/:id", uc.RemoveLocations) mux.PUT("/locations/:id", uc.UpdateLocations) server := http.Server{ Addr: "0.0.0.0:8080", Handler: mux, } server.ListenAndServe() }
func main() { id = 0 hmap = make(map[int]DataStorage) mux := httprouter.New() uc := controllers.NewUserController(getSession()) mux.GET("/locations/:id", uc.GetLocations) mux.POST("/locations/", uc.CreateLocations) mux.DELETE("/locations/:id", uc.RemoveLocations) mux.PUT("/locations/:id", uc.UpdateLocations) mux.POST("/trips/", CreateTrip) mux.GET("/trips/:trip_id", GetTrip) mux.PUT("/trips/:trip_id/request", CarRequest) server := http.Server{ Addr: "0.0.0.0:8080", Handler: mux, } server.ListenAndServe() }