本文整理汇总了Golang中github.com/labstack/echo.Echo类的典型用法代码示例。如果您正苦于以下问题:Golang Echo类的具体用法?Golang Echo怎么用?Golang Echo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Echo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Init
func Init(e *echo.Echo) {
const (
indexPath string = "public/views/index.html"
faviconPath string = "public/favicon.ico"
templatePath string = "public/views"
staticPath string = "public/static"
)
e.Index(indexPath)
e.Favicon(faviconPath)
e.Static("/static", staticPath)
initTemplate(e, templatePath)
}
示例2: Init
func Init(e *echo.Echo) {
e.Pre(middleware.RemoveTrailingSlash())
static.Init(e)
todoroutes.Init(e)
}
示例3: RegisterRoutes
// RegisterRoutes sets up the http request handlers with Echo
func RegisterRoutes(e *echo.Echo, db *mgo.Database, basePieURL string, service service.RiskService, fnDelayer *FunctionDelayer) {
e.Get("/pies/:id", func(c *echo.Context) (err error) {
pie := &plugin.Pie{}
id := c.Param("id")
if bson.IsObjectIdHex(id) {
query := db.C("pies").FindId(bson.ObjectIdHex(id))
err = query.One(pie)
if err == nil {
c.JSON(200, pie)
}
} else {
c.String(400, "Bad ID format for requested Pie. Should be a BSON Id")
}
return
})
e.Post("/calculate", func(c *echo.Context) (err error) {
patientID := c.Form("patientId")
fhirEndpointURL := c.Form("fhirEndpointUrl")
key := fmt.Sprintf("%[email protected]%s", patientID, fhirEndpointURL)
fnDelayer.Delay(key, func() {
service.Calculate(patientID, fhirEndpointURL, basePieURL)
})
return
})
}
示例4: apiRoute
// 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
}
示例5: SetupKeysRoutes
func SetupKeysRoutes(e *echo.Echo) {
e.Get("", listKeys)
e.Get("/:id", showKey)
e.Post("", createKey)
e.Put("/:id", updateKey)
e.Delete("/:id", deleteKey)
}
示例6: Init
func Init(e *echo.Echo, Debug bool) {
c := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"},
AllowCredentials: true,
Debug: Debug,
})
e.Use(standard.WrapMiddleware(c.Handler))
}
示例7: registerClient
func registerClient(e *echo.Echo) {
e.Get("/bundle.js", func(c *echo.Context) error {
return c.File("../client/bundle.js", "", false)
})
e.Get("/", func(c *echo.Context) error {
return c.File("../client/index.html", "", false)
})
}
示例8: Run
// Run ...
func Run(application *echo.Echo) {
var address = fmt.Sprintf("%s:%d", WebHost, WebPort)
log.Printf("starting webserver on %s", address)
if UseSSL {
application.RunTLS(address, CertFile, KeyFile)
} else {
application.Run(address)
}
}
示例9: InitRoutes
func InitRoutes(e *echo.Echo) {
h := new(handler)
e.Get("/json", h.json())
e.Get("/db", h.db())
e.Get("/queries/*", h.queries())
e.Get("/fortunes", h.fortunes())
e.Get("/updates/*", h.updates())
e.Get("/plaintext", h.plaintext())
}
示例10: registerRouterHandler
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)
}
示例11: OnStart
// OnStart ...
func (s *Server) OnStart(c *common.Config, e *echo.Echo) error {
go func() { s.sessionMgnt.Start() }()
e.Use(middleware.BasicAuth(s.Auth))
e.POST("/api/v1/server/tasks", s.CreateTask)
e.DELETE("/api/v1/server/tasks/:id", s.CancelTask)
e.GET("/api/v1/server/tasks/:id", s.QueryTask)
e.POST("/api/v1/server/tasks/status", s.ReportTask)
return nil
}
示例12: Set
func Set(e *echo.Echo) *echo.Echo {
e.Favicon("static/favicon.ico")
e.Static("/", "static")
e.Get("/", controller.Index)
e.Get("/eval/", controller.Eval)
e.Post("/eval/", controller.PostEval)
return e
}
示例13: serveStatic
func serveStatic(e *echo.Echo) {
for prefix, rootConf := range staticFileMap {
filterPrefixs = append(filterPrefixs, prefix)
if rootConf.isFile {
e.File(prefix, ROOT+rootConf.root)
} else {
e.Static(prefix, ROOT+rootConf.root)
}
}
}
示例14: Configure
// Configure setups routes and templates
func Configure(r *render.BufferedRender, e *echo.Echo) error {
// Add templates
err := r.Load("500", utils.TmplAbs("500.tmpl"), utils.TmplAbs("layouts", "black_base.tmpl"))
if err != nil {
return err
}
e.SetHTTPErrorHandler(HandleError)
e.Get("/500", FailOnPropouse)
// Add routes
return nil
}
示例15: SetRouting
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())
}