Exemple #1
0
func (tr *TaskRouter) Register(r martini.Router) {
	r.Get("", tr.GetAllTasks)
	r.Post("", tr.CreateTask)
	r.Get("/:id", tr.GetTask)
	r.Put("/:id", tr.CreateTask)
	r.Delete("/:id", tr.CancelTask)
}
Exemple #2
0
func (lr *SiteRouter) Register(r martini.Router) {

	r.Get("", lr.GetAll)
	r.Get("/:id", lr.GetSite)
	r.Put("/:id", lr.PutSite)
	r.Delete("/:id", lr.DeleteSite)

}
func (lr *ThingRouter) Register(r martini.Router) {

	r.Get("", lr.GetAll)
	r.Get("/:id", lr.GetThing)
	r.Put("/:id", lr.PutThing)
	r.Put("/:id/location", lr.PutThingLocation)
	r.Delete("/:id", lr.DeleteThing)

}
Exemple #4
0
func (lr *RoomRouter) Register(r martini.Router) {

	r.Get("", lr.GetAll)
	r.Post("", lr.PostNewRoom)
	r.Get("/:id", lr.GetRoom)
	r.Delete("/:id", lr.DeleteRoom)
	r.Put("/:id", lr.UpdateRoom)
	// r.Get("/:id/things", lr.GetThings) Not sure if this was used
	r.Put("/:id/calibrate", lr.PutCalibrateRoom)
	r.Put("/:id/apps/:appName", lr.PutAppRoomMessage)

}
func (this *EurekaRequestDelete) SetRoutes(r martini.Router) {
	r.Delete("/apps/:appId/:instanceId", this.requestUnregisterInstance)
}
Exemple #6
0
// BindRoutes binds API routes.
func BindRoutes(r martini.Router) {

	r.NotFound(func(req *http.Request, r render.Render) {
		r.JSON(http.StatusNotFound, []string{"The requested url does not exists."})
	})

	r.Get("/api/status", Status)

	// Registration
	r.Group("/api", func(r martini.Router) {
		r.Group("/accounts", func(r martini.Router) {
			r.Post("/register", binding.Bind(accounts.RegisterViewModel{}), NotificatorHandler(), accounts.Register)
		})
	}, GatekeeperRouteHandler())

	// DASHBOARD GATEKEEPER
	r.Group("/api", func(r martini.Router) {
		r.Group("/auth", func(r martini.Router) {
			r.Post("/password", binding.Bind(auth.PasswordRequest{}), auth.Password)
		})
	}, GatekeeperRouteHandler(), AccountScopeHandler(), RepositoryScopeHandler())

	//ADMIN
	r.Group("/api", func(r martini.Router) {
		r.Get("/accounts", accounts.Index)
		r.Post("/accounts", binding.Bind(accounts.AccountViewModel{}), accounts.Post)
		r.Delete("/:id", accounts.Delete)
	}, AdminRouteHandler())

	//Owner / Manager
	r.Group("/api", func(r martini.Router) {
		r.Group("/accounts", func(r martini.Router) {
			r.Get("/:id", accounts.Get)
			r.Put("/:id", binding.Bind(accounts.AccountViewModel{}), accounts.Put)
		})

		r.Get("/devices", devices.Index)
		r.Post("/devices", binding.Bind(devices.DeviceViewModel{}), devices.Post)
		r.Group("/devices", func(r martini.Router) {
			r.Get("/:id", devices.Get)
			r.Put("/:id", binding.Bind(devices.DeviceViewModel{}), devices.Put)
			r.Post("/register", binding.Bind(devices.DeviceViewModel{}), devices.Post)
			r.Delete("/:id", devices.Delete)
		})

		r.Get("/doors", doors.Index)
		r.Post("/doors", binding.Bind(doors.DoorViewModel{}), doors.Post)
		r.Group("/doors", func(r martini.Router) {
			r.Get("/:id", doors.Get)
			r.Put("/:id", binding.Bind(doors.DoorViewModel{}), doors.Put)
			r.Delete("/:id", doors.Delete)
		})

		r.Post("/people", binding.Bind(people.PersonViewModel{}), people.Post)
		r.Group("/people", func(r martini.Router) {
			r.Post("/sync", BridgeHandler(), people.Sync)
			r.Delete("/:id", people.Delete)
		})

	}, AccountScopeHandler(), RepositoryScopeHandler(), SecuredRouteHandler(), ManagerRestrictedRouteHandler())

	//Account
	r.Group("/api", func(r martini.Router) {
		r.Group("/accounts", func(r martini.Router) {
			r.Get("/:id", accounts.Get)
		})

		r.Post("/notifications", NotificatorHandler(), binding.Bind(notifications.ViewModel{}), notifications.Notify)

		r.Get("/people", people.Index)
		r.Group("/people", func(r martini.Router) {
			r.Get("/:id", people.Get)
			r.Put("/:id", binding.Bind(people.PersonViewModel{}), people.Put)
		})

	}, AccountScopeHandler(), RepositoryScopeHandler(), SecuredRouteHandler())
}