Пример #1
0
func SetupRoutes() {
	for _, route := range routes {
		for _, method := range route.methods {
			switch method {
			case "GET":
				goji.Get(route.url, route.handler)
				break
			case "POST":
				goji.Post(route.url, route.handler)
				break
			case "PUT":
				goji.Put(route.url, route.handler)
				break
			case "PATCH":
				goji.Patch(route.url, route.handler)
				break
			case "DELETE":
				goji.Delete(route.url, route.handler)
				break
			default:
				goji.Handle(route.url, route.handler)
			}
		}
	}
}
Пример #2
0
func (s *GossamerServer) Start() {
	goji.Get("/", s.HandleWebUiIndex)
	goji.Get("/things.html", s.HandleWebUiThings)
	goji.Get("/sensors.html", s.HandleWebUiSensors)
	goji.Get("/observations.html", s.HandleWebUiObservations)
	goji.Get("/observedproperties.html", s.HandleWebUiObservedProperties)
	goji.Get("/locations.html", s.HandleWebUiLocations)
	goji.Get("/datastreams.html", s.HandleWebUiDatastreams)
	goji.Get("/featuresofinterest.html", s.HandleWebUiFeaturesOfInterest)
	goji.Get("/historiclocations.html", s.HandleWebUiHistoricLocations)
	goji.Get("/css/*", s.HandleWebUiResources)
	goji.Get("/img/*", s.HandleWebUiResources)
	goji.Get("/js/*", s.HandleWebUiResources)

	goji.Get("/v1.0", s.handleRootResource)
	goji.Get("/v1.0/", s.handleRootResource)

	goji.Get("/v1.0/*", s.HandleGet)
	goji.Post("/v1.0/*", s.HandlePost)
	goji.Put("/v1.0/*", s.HandlePut)
	goji.Delete("/v1.0/*", s.HandleDelete)
	goji.Patch("/v1.0/*", s.HandlePatch)

	flag.Set("bind", ":"+strconv.Itoa(s.port))

	log.Println("Start Server on port ", s.port)
	goji.Serve()
}
Пример #3
0
func init() {
	http.Handle("/", goji.DefaultMux)

	goji.Get("/", indexHandler)
	goji.Get("/api/v1/spots", spotHandler)
	goji.Get("/api/v1/spots/:spotCode", spotGetHandler)
	goji.Get("/edit/", indexHandler)
	goji.Get("/edit/v1/spots", spotHandler)
	goji.Get("/edit/v1/spots/:spotCode", spotGetHandler)
	goji.Post("/edit/v1/spots", spotCreateHandler)
	goji.Patch("/edit/v1/spots/:spotCode", spotUpdateHandler)
	//	goji.Delete("/edit/v1/spots/:spotCode", spotDeleteHandler)
}
Пример #4
0
func main() {
	//
	// Event queue hadling
	//
	err := players.StartEventProcessor()
	if err != nil {
		fmt.Printf("%+v", err.Error)
		println("Could not initialize event queue. Exiting")
		os.Exit(1)
	}

	//
	// HTTP Serving
	//
	c := cors.New(cors.Options{
		AllowedOrigins: []string{"*"},
		AllowedHeaders: []string{"*"},
		AllowedMethods: []string{"GET", "PUT", "PATCH", "POST", "OPTIONS", "DELETE"},
	})
	goji.Use(c.Handler)
	goji.Use(middleware.TokenHandler)

	goji.Post("/login", appHandler(login))

	goji.Get("/players", appHandler(listAllPlayers))
	goji.Post("/players", appHandler(createNewPlayer))
	goji.Get("/players/quotes", appHandler(getAllPlayerQuotes))
	goji.Get("/players/:uuid", appHandler(getPlayer))
	goji.Put("/players/:uuid", appHandler(updatePlayer))
	goji.Post("/players/:uuid/quotes", appHandler(addPlayerQuote))
	goji.Get("/players/:uuid/profile", appHandler(getPlayerProfile))
	goji.Put("/players/:uuid/profile", appHandler(updatePlayerProfile))
	goji.Get("/players/:uuid/user", appHandler(getUserForPlayer))
	goji.Put("/players/:uuid/user", appHandler(setUserForPlayer))
	goji.Put("/players/:uuid/user/password", appHandler(setUserPassword))
	goji.Put("/players/:uuid/user/settings", appHandler(setUserSettings))
	goji.Put("/players/:uuid/user/admin", appHandler(setUserAdmin))
	goji.Put("/players/:uuid/gossip", appHandler(setPlayerGossip))
	goji.Patch("/players/:uuid/gossip", appHandler(setPlayerGossip))
	goji.Delete("/players/:uuid/gossip", appHandler(resetPlayerGossip))
	goji.Get("/players/:uuid/debts", appHandler(showPlayerDebt))
	goji.Delete("/players/:uuid/debts", appHandler(resetPlayerDebts))
	goji.Get("/players/:uuid/credits", appHandler(showPlayerCredits))
	goji.Post("/players/:uuid/debts", appHandler(addPlayerDebt))
	goji.Delete("/players/:uuid/debts/:debtuuid", appHandler(settlePlayerDebt))
	goji.Put("/players/:uuid/votes", appHandler(setPlayerVotes))
	goji.Patch("/players/:uuid/votes", appHandler(setPlayerVotes))
	goji.Post("/players/notification_test", appHandler(testPlayerNotify))

	goji.Post("/users", appHandler(createNewUser))

	goji.Get("/locations", appHandler(listAllLocations))
	goji.Post("/locations", appHandler(createNewLocation))
	goji.Get("/locations/:uuid", appHandler(getLocation))
	goji.Put("/locations/:uuid", appHandler(updateLocationProfile))
	goji.Patch("/locations/:uuid", appHandler(updateLocationProfile))
	goji.Post("/locations/:uuid/pictures", appHandler(addLocationPicture))

	goji.Get("/tournaments", appHandler(listAllTournaments))
	goji.Post("/tournaments", appHandler(createNewTournament))
	goji.Get("/tournaments/:uuid", appHandler(getTournament))
	goji.Put("/tournaments/:uuid", appHandler(updateTournamentInfo))
	goji.Patch("/tournaments/:uuid", appHandler(updateTournamentInfo))
	goji.Put("/tournaments/:uuid/played", appHandler(setTournamentPlayed))
	goji.Get("/tournaments/:uuid/result", appHandler(getTournamentResult))
	goji.Put("/tournaments/:uuid/result", appHandler(setTournamentResult))
	goji.Post("/tournaments/:uuid/noshows", appHandler(addTournamentNoShow))
	goji.Delete("/tournaments/:uuid/noshows/:playeruuid", appHandler(removeTournamentNoShow))

	goji.Get("/seasons", appHandler(listAllSeasons))
	goji.Get("/seasons/stats", appHandler(getTotalStats))
	goji.Get("/seasons/standings", appHandler(getTotalStandings))
	goji.Get("/seasons/titles", appHandler(getTotalTitles))
	goji.Get("/seasons/:year/tournaments", appHandler(listTournamentsBySeason))
	goji.Get("/seasons/:year/standings", appHandler(getSeasonStandings))
	goji.Get("/seasons/:year/titles", appHandler(getSeasonTitles))
	goji.Get("/seasons/:year/stats", appHandler(getSeasonStats))

	goji.Get("/caterings", appHandler(listAllCaterings))
	goji.Post("/caterings", appHandler(createNewCatering))
	goji.Get("/caterings/:uuid", appHandler(getCatering))
	goji.Put("/caterings/:uuid", appHandler(updateCateringInfo))
	goji.Patch("/caterings/:uuid", appHandler(updateCateringInfo))
	goji.Post("/caterings/:uuid/votes", appHandler(addCateringVote))
	goji.Put("/caterings/:uuid/votes/:playeruuid", appHandler(updateCateringVote))

	goji.Get("/news", appHandler(listAllNews))
	goji.Get("/news/:uuid", appHandler(getNewsItem))
	goji.Patch("/news/:uuid", appHandler(updateNewsItem))
	goji.Post("/news", appHandler(createNewNewsItem))
	goji.Post("/news/:uuid/comments", appHandler(addNewsComment))
	// TODO: Comment updates/deletion

	goji.Serve()
}
Пример #5
0
func (mux *Mux) Patch(pattern web.PatternType, h handler) {
	goji.Patch(pattern, func(c web.C, w http.ResponseWriter, r *http.Request) {
		mux.handleRequest(c, w, r, h)
	})
}
Пример #6
0
func (ctr *Controller) RoutePatch(rt *Route) {
	goji.Patch(rt.Pattern, handlerWrap(rt))
}