Exemple #1
0
// apiRoute contains router groups for API
func (a *App) apiRoute(e *echo.Echo) error {
	apiUrl, err := a.conf.Get("api-url")
	if err != nil {
		return err
	}
	//General API
	g := e.Group(apiUrl.(string))
	//auth
	g.Post("/auth", a.login)
	//oauth
	a.fb, err = oauth.NewFacebook(a)
	if err != nil {
		return err
	}
	fbg := g.Group("/oauth")
	fbg.Get("/facebook", a.facebookAuth)
	fbg.Get("/facebook/redirect", a.facebookRedirect)
	//tasks
	tokenizer := jwt.NewTokenizer(a)
	tg := g.Group("/tasks", tokenizer.Check())
	tg.Post("", a.create)
	tg.Get("/:id", a.retrieve)
	tg.Get("", a.retrieveAll)
	tg.Put("/:id", a.update)
	tg.Delete("/:id", a.delete)
	return nil
}
Exemple #2
0
func registerRouterHandler(e *echo.Echo) {
	a := e.Group("/admin")
	a.Get("/:id", func(c *echo.Context) error {
		return c.String(http.StatusOK, "/admin/"+c.Param("id"))
	})
	a.Get("/users/:name", func(c *echo.Context) error {
		return c.String(http.StatusOK, c.Param("name"))
	})
	a.Post("/login", login)
}
Exemple #3
0
func SetRouting(e *echo.Echo) {
	log.Info("Start set api's routing")
	g := e.Group("/api")

	// Members
	g.Get("/members", GetAllMembers())
	g.Get("/members/:id", GetMember())
	g.Post("/members", CreateMember())

	// Iterations
	g.Get("/iterations", GetAllIterations())
	g.Get("/iterations/:id/tasks", GetIterationTasks())
	g.Post("/iterations", CreateIteration())

	// Task
	g.Post("/tasks", CreateTask())
}
func RegisterController(name string, e *echo.Echo, m []echo.Middleware, dal DataAccessLayer, config Config) {
	rc := NewResourceController(name, dal)
	rcBase := e.Group("/" + name)
	rcBase.Get("", rc.IndexHandler)
	rcBase.Post("", rc.CreateHandler)
	rcBase.Delete("", rc.ConditionalDeleteHandler)

	rcItem := rcBase.Group("/:id")
	rcItem.Get("", rc.ShowHandler)
	rcItem.Put("", rc.UpdateHandler)
	rcItem.Delete("", rc.DeleteHandler)

	if len(m) > 0 {
		rcBase.Use(m...)
	}

	if config.UseSmartAuth {
		rcBase.Use(SmartAuthHandler(name))
	}
}
// InitAuthWebServices Wire Auth Services ...
func InitAuthWebServices(app *echo.Echo) {
	gProvider := app.Group("/auth")
	gProvider.Get("", getProviders)
	gProvider.Get("/:provider", redirectHandler)
	gProvider.Get("/:provider/callback", callbackHandler)
}