예제 #1
6
파일: routes.go 프로젝트: cultome/tickets
func prepareRoutes(router *gin.Engine) {
	// Web Resources
	router.Static("/static", "web/dist")

	// API Routes
	api := router.Group("/api/v1")
	admin := api.Group("/admin")
	public := api.Group("/public")
	registered := api.Group("/")
	sameRegisteredUser := api.Group("/user")

	prepareMiddleware(admin, public, registered, sameRegisteredUser)

	admin.GET("/users", listUsers)
	admin.GET("/places", listPlaces)
	admin.POST("/places", createPlace)
	admin.POST("/events", createEvent)
	admin.PUT("/place/:placeId", updatePlace)
	admin.PUT("/event/:eventId", updateEvent)
	admin.DELETE("/event/:eventId", cancelEvent)

	sameRegisteredUser.GET("/:userId", getUser)
	sameRegisteredUser.PUT("/:userId", updateUser)
	sameRegisteredUser.DELETE("/:userId", disableUser)

	registered.POST("/buy/:seatId", buyTicket)

	public.GET("/place/:placeId", getPlace)
	public.GET("/events", listEvents)
	public.GET("/event/:eventId", getEvent)
	public.POST("/users", createUser) // TODO Checar, me huele raro......
	public.POST("/login", loginUser)
}
예제 #2
1
// SetRoutes sets the crud and migration (if them exists) routes
func SetRoutes(r *gin.Engine) {
	taskRoute := r.Group("/api/task")

	taskRoute.Use(jwt.Auth(config.TokenSecret))

	// Task CRUD
	taskRoute.GET("/*id", taskRetrieveRoute)
	taskRoute.POST("/", taskCreateRoute)
	taskRoute.PUT("/:id", taskUpdateRoute)
	taskRoute.DELETE("/:id", taskDeleteRoute)
}
예제 #3
0
파일: api.go 프로젝트: ravaj-group/farmer
func registerRoutes(server *gin.Engine) {
	podRoute := server.Group("/pod")
	{
		podRoute.POST("/create", PodCreate)
		podRoute.GET("/state/:pod", PodState)
	}
}
예제 #4
0
func mapRoutes(router *gin.Engine) {

	router.Use(cors.Middleware(cors.Config{
		Origins: "http://openbonfires.github.io, https://openbonfires.github.io",
	}))

	//mapped router for authenticated urls only
	api := router.Group("/api")
	api.GET("/randomquote", func(c *gin.Context) {
		res, err := http.Get("http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en")
		if err == nil {
			defer res.Body.Close()
			body, err := ioutil.ReadAll(res.Body)
			if err == nil {
				c.String(http.StatusOK, string(body))
			} else {
				c.String(http.StatusInternalServerError, "Unable to read the response date from the random quotes API.")
			}
		} else {
			c.String(http.StatusInternalServerError, "Unable to communicate with random quotes API.")
		}
	})

	//All other requests
	router.Use(func(c *gin.Context) {
		c.String(http.StatusNotFound, "Requested url does not exist")
		c.Abort()
	})
}
예제 #5
0
func Init(router *gin.Engine, DB *db.Session, fn func() gin.HandlerFunc) {
	// Simple group: v1
	api := &API{DB}
	v1 := router.Group("/v1")
	{
		v1.Use(fn())
		policies := v1.Group("policies")
		{
			policies.POST("/", api.createPolicy)
			policies.GET("/", api.getPolicies)
			policies.DELETE("/", api.deletePolicies)
			policies.DELETE("/:id", api.deletePolicy)
			policies.PUT("/:id", api.updatePolicy)
		}
		res := v1.Group("resources")
		{
			res.POST("/", api.createResource)
			res.GET("/:type", api.getResources)
			//res.GET("/:type/:id", api.getResources)
			res.DELETE("/", api.deleteResources)
			res.DELETE("/:id", api.deleteResource)
			res.PUT("/:id", api.updateResource)
		}
	}

}
예제 #6
0
파일: routes.go 프로젝트: jlertle/pgweb
func SetupRoutes(router *gin.Engine) {
	router.GET("/", GetHome)
	router.GET("/static/*path", GetAsset)

	api := router.Group("/api")
	{
		SetupMiddlewares(api)

		api.GET("/info", GetInfo)
		api.POST("/connect", Connect)
		api.GET("/databases", GetDatabases)
		api.GET("/connection", GetConnectionInfo)
		api.GET("/activity", GetActivity)
		api.GET("/schemas", GetSchemas)
		api.GET("/tables", GetTables)
		api.GET("/tables/:table", GetTable)
		api.GET("/tables/:table/rows", GetTableRows)
		api.GET("/tables/:table/info", GetTableInfo)
		api.GET("/tables/:table/indexes", GetTableIndexes)
		api.GET("/query", RunQuery)
		api.POST("/query", RunQuery)
		api.GET("/explain", ExplainQuery)
		api.POST("/explain", ExplainQuery)
		api.GET("/history", GetHistory)
		api.GET("/bookmarks", GetBookmarks)
	}
}
예제 #7
0
파일: web.go 프로젝트: robvdl/gcms
// setupRoutes is an internal method where we setup application routes
func setupRoutes(r *gin.Engine) {
	// TODO: home route "/" is not yet defined.
	// r.GET("/", ...)

	// static files served by application
	r.Static("/static", "./static")

	// auth urls for the login form and logout url
	r.GET("/login", auth.Login)
	r.POST("/login", auth.Login)
	r.GET("/logout", auth.Logout)

	// sessionResource is a special auth api resource, with POST and DELETE
	// endpoints used for logging a user in or out.
	sessionResource := r.Group("/api/session")
	{
		sessionResource.POST("", auth.LoginAPI)
		sessionResource.DELETE("", auth.LogoutAPI)
	}

	// admin urls
	adminRoutes := r.Group("/admin", auth.LoginRequired())
	{
		adminRoutes.GET("", admin.Admin)
		adminRoutes.GET("/json", admin.JSONTest)
	}
}
예제 #8
0
파일: topics.go 프로젝트: vmalguy/tat
// InitRoutesTopics initialized routes for Topics Controller
func InitRoutesTopics(router *gin.Engine) {
	topicsCtrl := &controllers.TopicsController{}

	g := router.Group("/")
	g.Use(CheckPassword())
	{
		g.GET("/topics", topicsCtrl.List)
		g.POST("/topic", topicsCtrl.Create)
		g.DELETE("/topic/*topic", topicsCtrl.Delete)
		g.GET("/topic/*topic", topicsCtrl.OneTopic)

		g.PUT("/topic/add/parameter", topicsCtrl.AddParameter)
		g.PUT("/topic/remove/parameter", topicsCtrl.RemoveParameter)

		g.PUT("/topic/add/rouser", topicsCtrl.AddRoUser)
		g.PUT("/topic/remove/rouser", topicsCtrl.RemoveRoUser)
		g.PUT("/topic/add/rwuser", topicsCtrl.AddRwUser)
		g.PUT("/topic/remove/rwuser", topicsCtrl.RemoveRwUser)
		g.PUT("/topic/add/adminuser", topicsCtrl.AddAdminUser)
		g.PUT("/topic/remove/adminuser", topicsCtrl.RemoveAdminUser)

		g.PUT("/topic/add/rogroup", topicsCtrl.AddRoGroup)
		g.PUT("/topic/remove/rogroup", topicsCtrl.RemoveRoGroup)
		g.PUT("/topic/add/rwgroup", topicsCtrl.AddRwGroup)
		g.PUT("/topic/remove/rwgroup", topicsCtrl.RemoveRwGroup)
		g.PUT("/topic/add/admingroup", topicsCtrl.AddAdminGroup)
		g.PUT("/topic/remove/admingroup", topicsCtrl.RemoveAdminGroup)
		g.PUT("/topic/param", topicsCtrl.SetParam)
	}
}
예제 #9
0
파일: routers.go 프로젝트: Gr1N/pacman
// Init initializes application routers.
func Init(g *gin.Engine) {
	g.Use(middleware.UserFromToken())

	// Home page.
	g.GET("/", Home)

	// Health check group.
	h := g.Group("/h")
	{
		h.GET("/ping", health.Ping)
	}

	// User related group.
	u := g.Group("/user")
	{
		usin := u.Group("/signin")
		usin.Use(middleware.NotAuthenticated())
		{
			usin.POST("/:service", auth.SignIn)
			usin.GET("/:service/complete", auth.SignInComplete)
		}

		urepos := u.Group("/repos")
		urepos.Use(middleware.Authenticated())
		{
			urepos.GET("/:service", repos.ReposList)
			urepos.PATCH("/:service", repos.ReposUpdate)
		}
	}
}
예제 #10
0
// wire up the greetings routes
func initGreetings(e *gin.Engine, f engine.EngineFactory, endpoint string) {
	greeter := &greeter{f.NewGreeter()}
	g := e.Group(endpoint)
	{
		g.GET("", greeter.list)
		g.POST("", greeter.add)
	}
}
예제 #11
0
func (r *TurmaResource) register(router *gin.Engine) {
	grupo := router.Group("/ges/v1/api")

	grupo.GET("/turmas", r.obterTodas)
	grupo.POST("/turmas", r.cadastrar)
	grupo.PUT("/turmas/:id", r.alterar)
	grupo.DELETE("/turmas/:id", r.excluir)
}
예제 #12
0
func Register(r *gin.Engine) {
	api(r.Group("/api"))

	r.GET("/", showIndex)
	r.GET("/h/:_", showIndex)
	r.GET("/p/:_", showIndex)

}
예제 #13
0
func buildRoutes(r *gin.Engine) {
	v1 := r.Group("/v1")
	{
		v1.GET(encryptPath, encryptContext())
		v1.POST(encryptPath, newEncryptContext())
		v1.GET(decryptPath, decryptContext())
		v1.GET(echoPath, echoContext())
	}
}
예제 #14
0
파일: front.go 프로젝트: Exquance/phabulous
// Register registers the route handlers for this controller
func (f *FrontController) Register(r *gin.Engine) {
	front := r.Group("/")
	{
		front.GET("/", f.getIndex)
		front.GET("/healthcheck", f.getHealthCheck)
	}

	r.NoRoute(f.getNotFound)
}
예제 #15
0
func configApi(engine *gin.Engine) {
	api := engine.Group("/api")
	{
		api.GET("/", func(c *gin.Context) { c.Writer.WriteHeader(200) })
		api.POST("/todos", NewTodo)
		api.GET("/todos", ListTodos)
		api.DELETE("/todos/:id", DeleteTodo)
		api.PUT("/todos/:id", UpateTodo)
	}
}
예제 #16
0
func Init(router *gin.Engine, DB *db.Session) {
	// Simple group: login
	l := &Login{DB}
	loginRouter := router.Group("/login")
	{
		loginRouter.POST("/register", l.registerUser)
		loginRouter.POST("/authorize", l.loginUser)
		loginRouter.GET("/logout", l.logoutUser)
		loginRouter.DELETE("/remove", l.deleteSelf)
	}
}
예제 #17
0
파일: presences.go 프로젝트: vmalguy/tat
// InitRoutesPresences initialized routes for Presences Controller
func InitRoutesPresences(router *gin.Engine) {
	presencesCtrl := &controllers.PresencesController{}
	g := router.Group("/")
	g.Use(CheckPassword())
	{
		// List Presences
		g.GET("presences/*topic", presencesCtrl.List)
		// Add a presence and get list
		g.POST("presenceget/*topic", presencesCtrl.CreateAndGet)
	}
}
예제 #18
0
func (r *gin.Engine) UseApi() error {

	eventsV1 := r.Group("/api/v1/events")
	{
		eventsV1.GET("/:eventId/:orderId/confirm", confirmOrder)
		eventsV1.GET("/:eventId/:orderId", getOrder)
		eventsV1.GET("/:eventId/:orderId/state", getState)
		eventsV1.POST("/:eventId/:orderId/billinginfo", updateBillingInfo)
		eventsV1.POST("/:eventId", createOrder)
	}

	return nil
}
예제 #19
0
// RouteAPI contains router groups for API
func RouteAPI(parentRoute *gin.Engine) {
	route := parentRoute.Group(config.APIURL)
	{
		v1.Users(route)
		v1.Roles(route)
		v1.Authentications(route)
		v1.Articles(route)
		v1.Locations(route)
		v1.Upload(route)
		v1.Experiments(route)
		v1.Oauth(route)
	}

}
예제 #20
0
파일: mount.go 프로젝트: itpkg/chaos
//Mount mount web
func (p *Engine) Mount(r *gin.Engine) {
	rg := r.Group("/ops/mail", p.Jwt.MustRolesHandler("ops"))
	rg.GET("/domains", web.Rest(p.indexDomain))
	rg.POST("/domains", web.Rest(p.createDomain))
	rg.DELETE("/domains/:id", web.Rest(p.deleteDomain))

	rg.GET("/users", web.Rest(p.indexUser))
	rg.POST("/users", web.Rest(p.createUser))
	rg.DELETE("/users/:id", web.Rest(p.deleteUser))

	rg.GET("/aliases", web.Rest(p.indexAlias))
	rg.POST("/aliases", web.Rest(p.createAlias))
	rg.DELETE("/aliases/:id", web.Rest(p.deleteAlias))
}
예제 #21
0
파일: api.go 프로젝트: fmr/kanban
/*
New creares a new API instance with all routes configured
*/
func New(r *gin.Engine, prefix string, db *db.DB) *gin.RouterGroup {

	api := r.Group(prefix)

	api.Use(func(c *gin.Context) {
		c.Set("db", db)
	})

	cardRoutes(api, "/board/")
	taskRoutes(api, "/task/")

	return api

}
예제 #22
0
파일: rotas.go 프로젝트: viliamjr/favoritos
// RegistrarRotas realiza o registro de todas as rotas da aplicação.
func RegistrarRotas(r *gin.Engine, usuario, senha string) {

	// Habilitando esquema de autorização simples
	auth := r.Group("/", gin.BasicAuth(gin.Accounts{usuario: senha}))

	auth.GET("/", Raiz)

	auth.GET("/pagina/:pag", Pagina)

	auth.GET("/formulario", Formulario)

	auth.POST("/salvar", Salvar)

	auth.GET("/remover/:id", Remover)

	auth.GET("/editar/:id", Editar)
}
예제 #23
0
func LoadPage(parentRoute *gin.Engine) {
	//type Page struct {
	//    Title string
	//}

	parentRoute.SetHTMLTemplate(template.Must(template.ParseFiles("frontend/canjs/templates/message.html", "frontend/canjs/templates/app.html", "frontend/canjs/templates/base.html", "frontend/canjs/templates/404.html")))
	log.Debug("url : " + config.StaticUrl)
	log.Debug("guid : " + config.Guid)
	log.Debug("path : " + staticPath)
	parentRoute.Static(config.StaticUrl+"/"+config.Guid, staticPath)
	// route.ServeFiles doesn't exist in the current version of gin. If you want to use this, use the 59d949d35080b83864dbeafadecef112d46aaeee.
	//parentRoute.ServeFiles(config.StaticUrl+"/"+config.Guid+"/*filepath", http.Dir(staticPath))
	parentRoute.NoRoute(func(c *gin.Context) {
		c.HTML(404, "404.html", map[string]string{"language": config.DefaultLanguage, "title": config.Title})
	})

	route.Route(parentRoute.Group(""))
}
예제 #24
0
func SetupRoutes(r *gin.Engine, s *socketio.Server) {
	//Oauth Authenticaton and Callbacks
	r.GET("/auth/github/callback", providerCallback)
	r.GET("/auth/github", providerAuth)

	//Template Route
	r.GET("/templates", templateHandler)

	//Socket.io Route
	r.GET("/socket.io/", func(c *gin.Context) {
		s.ServeHTTP(c.Writer, c.Request)
	})

	//Api endpoints
	a := r.Group("api")
	a.GET("/activity", getActivity)
	a.GET("/users", getUsers)
}
예제 #25
0
파일: stats.go 프로젝트: vmalguy/tat
// InitRoutesStats initialized routes for Stats Controller
func InitRoutesStats(router *gin.Engine) {
	statsCtrl := &controllers.StatsController{}

	admin := router.Group("/stats")
	admin.Use(CheckPassword(), CheckAdmin())
	{
		admin.GET("/count", statsCtrl.Count)
		admin.GET("/instance", statsCtrl.Instance)
		admin.GET("/distribution", statsCtrl.Distribution)
		admin.GET("/db/stats", statsCtrl.DBStats)
		admin.GET("/db/replSetGetConfig", statsCtrl.DBReplSetGetConfig)
		admin.GET("/db/serverStatus", statsCtrl.DBServerStatus)
		admin.GET("/db/replSetGetStatus", statsCtrl.DBReplSetGetStatus)
		admin.GET("/db/collections", statsCtrl.DBStatsCollections)
		admin.GET("/db/slowestQueries", statsCtrl.DBGetSlowestQueries)
		admin.GET("/checkHeaders", statsCtrl.CheckHeaders)
	}
}
예제 #26
0
파일: mount.go 프로젝트: itpkg/chaos
//Mount mount router
func (p *Engine) Mount(r *gin.Engine) {

	gf := r.Group("/reading", p.Jwt.CurrentUserHandler(false))
	gf.GET("/blogs", p.Cache.Page(time.Hour*24, web.Rest(p.indexBlogs)))
	gf.GET("/blog/*name", p.Cache.Page(time.Hour*24, p.showBlog))
	gf.GET("/books", p.Cache.Page(time.Hour*24, web.Rest(p.indexBooks)))
	gf.GET("/book/:id", p.Cache.Page(time.Hour*24, p.indexBook))
	gf.GET("/book/:id/*name", p.Cache.Page(time.Hour*24, p.showBook))
	gf.GET("/dict", p.getDict)
	gf.POST("/dict", p.postDict)

	gt := r.Group("/reading", p.Jwt.CurrentUserHandler(true))
	gt.DELETE("/books/:id", p.Jwt.MustAdminHandler(), web.Rest(p.deleteBook))
	gt.GET("/notes", web.Rest(p.indexNotes))
	gt.POST("/notes", web.Rest(p.createNote))
	gt.GET("/notes/:id", web.Rest(p.showNote))
	gt.POST("/notes/:id", web.Rest(p.updateNote))
	gt.DELETE("/notes/:id", web.Rest(p.deleteNote))
}
예제 #27
0
// Register all endpoint handlers
func Register(engine *gin.Engine) {
	engine.Use(Limiter)
	engine.Use(Recovery)

	dbGroup := engine.Group("")
	dbGroup.Use(Database)

	dbGroup.GET("/check", checkGet)
	dbGroup.POST("/request/google", requestGooglePost)
	dbGroup.POST("/request/saml", requestSamlPost)
	dbGroup.GET("/callback/google", callbackGoogleGet)
	dbGroup.POST("/callback/saml", callbackGoogleGet)
	dbGroup.GET("/update/google", updateGoogleGet)

	dbGroup.POST("/v1/request/google", requestGoogle2Post)
	dbGroup.POST("/v1/request/saml", requestSamlPost)
	dbGroup.GET("/v1/callback/google", callbackGoogleGet)
	dbGroup.POST("/v1/callback/saml", callbackSamlPost)
	dbGroup.GET("/v1/update/google", updateGoogleGet)
}
예제 #28
0
파일: ginja.go 프로젝트: jens-a-e/ginja
// New returns a new ginja.Api struct
func New(server *gin.Engine, config Config, middleware ...gin.HandlerFunc) *GinApi {
	config.ApplyDefaults()
	api := &GinApi{
		RouterGroup: server.Group(config.buildUrl()),
		Api:         Api{Config: config},
	}

	api.init()

	api.Use(middleware...)

	// TODO extract!
	if api.MountStats {
		api.GET(api.StatsURL, func(c *gin.Context) {
			c.JSON(http.StatusOK, gin.H{"config": api.Config})
		})
	}

	return api
}
예제 #29
0
파일: mount.go 프로젝트: itpkg/chaos
//Mount mount routes
func (p *Engine) Mount(r *gin.Engine) {
	ag := r.Group("/admin", p.Jwt.CurrentUserHandler(true), p.Jwt.MustAdminHandler())
	ag.GET("/site/info", p.getAdminSiteInfo)
	ag.POST("/site/info", web.Rest(p.postAdminSiteInfo))
	ag.DELETE("/cache", web.Rest(p.deleteAdminCache))
	ag.GET("/notices", web.Rest(p.getNotices))
	ag.POST("/notices", web.Rest(p.postNotices))
	ag.DELETE("/notices/:id", web.Rest(p.deleteNotice))

	r.GET("/notices", p.Cache.Page(time.Hour*24, web.Rest(p.getNotices)))

	r.GET("/personal/self", p.Jwt.CurrentUserHandler(true), web.Rest(p.getPersonalSelf))
	r.GET("/personal/logs", p.Jwt.CurrentUserHandler(true), web.Rest(p.getPersonalLogs))
	r.DELETE("/personal/signOut", p.Jwt.CurrentUserHandler(true), p.deleteSignOut)

	r.GET("/locales/:lang", p.Cache.Page(time.Hour*24, p.getLocale))
	r.GET("/site/info", p.Cache.Page(time.Hour*24, p.getSiteInfo))

	r.POST("/oauth2/callback", web.Rest(p.postOauth2Callback))
}
예제 #30
0
파일: groups.go 프로젝트: vmalguy/tat
// InitRoutesGroups initialized routes for Groups Controller
func InitRoutesGroups(router *gin.Engine) {

	groupsCtrl := &controllers.GroupsController{}

	g := router.Group("/")
	g.Use(CheckPassword())
	{
		g.GET("/groups", groupsCtrl.List)

		g.PUT("/group/add/user", groupsCtrl.AddUser)
		g.PUT("/group/remove/user", groupsCtrl.RemoveUser)
		g.PUT("/group/add/adminuser", groupsCtrl.AddAdminUser)
		g.PUT("/group/remove/adminuser", groupsCtrl.RemoveAdminUser)

		admin := router.Group("/group")
		admin.Use(CheckPassword(), CheckAdmin())
		{
			admin.POST("", groupsCtrl.Create)
		}
	}
}