• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang echo.Echo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/labstack/echo.Echo的典型用法代码示例。如果您正苦于以下问题:Golang Echo类的具体用法?Golang Echo怎么用?Golang Echo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Echo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:schaffers,项目名称:typed,代码行数:14,代码来源:common.go


示例2: Init

func Init(e *echo.Echo) {
	e.Pre(middleware.RemoveTrailingSlash())

	static.Init(e)

	todoroutes.Init(e)
}
开发者ID:bgdsh,项目名称:playground,代码行数:7,代码来源:routes.go


示例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
	})
}
开发者ID:intervention-engine,项目名称:riskservice,代码行数:27,代码来源:routes.go


示例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
}
开发者ID:arbrix,项目名称:go-test,代码行数:28,代码来源:app.go


示例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)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:7,代码来源:keys.go


示例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))
}
开发者ID:steveoc64,项目名称:godev,代码行数:9,代码来源:echocors.go


示例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)
	})
}
开发者ID:wkjagt,项目名称:skeletor,代码行数:9,代码来源:server.go


示例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)
	}
}
开发者ID:gkarwchan,项目名称:GoAngularBrowserifyBoilerplate,代码行数:10,代码来源:app.go


示例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())
}
开发者ID:nathana1,项目名称:FrameworkBenchmarks,代码行数:9,代码来源:common.go


示例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)
}
开发者ID:schaffers,项目名称:typed,代码行数:10,代码来源:router.go


示例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
}
开发者ID:xtfly,项目名称:gofd,代码行数:12,代码来源:server.go


示例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
}
开发者ID:sheercat,项目名称:evaltmpl,代码行数:11,代码来源:router.go


示例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)
		}
	}
}
开发者ID:studygolang,项目名称:studygolang,代码行数:11,代码来源:static.go


示例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
}
开发者ID:cedmundo,项目名称:site,代码行数:14,代码来源:handlers.go


示例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())
}
开发者ID:ggoblin,项目名称:goblin,代码行数:17,代码来源:mainhandler.go


示例16: Setup

// Setup theme
func Setup(e *echo.Echo, mode string) {
	var t Template
	if mode == "dev" {
		// development
		t.templates = template.Must(template.ParseGlob("internals/themes/" + Theme + "/*.html"))

		e.Static("/assets", "internals/themes/"+Theme+"/assets")
		e.File("/favicon.ico", "internals/themes/"+Theme+"favicon.ico")
	} else {
		// production
		t.templates = template.Must(template.ParseGlob("public/themes/" + Theme + "/*.html"))

		e.Static("/assets", "public/themes/"+Theme+"/assets")
		e.File("/favicon.ico", "public/themes/"+Theme+"favicon.ico")
	}

	e.SetRenderer(&t)
}
开发者ID:mewben,项目名称:onix,代码行数:19,代码来源:theme.go


示例17: RegisterController

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))
	}
}
开发者ID:intervention-engine,项目名称:riskservice,代码行数:20,代码来源:routing.go


示例18: registerRoute

//	注册路由
func registerRoute(e *echo.Echo) {

	e.Get("/", welcome)
	e.Favicon("favicon.ico")

	e.Get("/:market/:code/:start/:end/1m", queryPeroid60)
}
开发者ID:ifzz,项目名称:stockrecorder,代码行数:8,代码来源:route.go


示例19: Init

func Init(e *echo.Echo) {
	e.Use(middleware.Static("node_modules"))

	if env := os.Getenv("GO_ENV"); env == "" {
		e.Use(middleware.Static("client/dev"))
	} else {
		e.Use(middleware.Static("client/dist"))
	}
}
开发者ID:bgdsh,项目名称:playground,代码行数:9,代码来源:static.go


示例20: InitializeRenderers

func InitializeRenderers(e *echo.Echo) error {
	//e.Use(middleware.Logger())
	e.Use(middleware.Recover())
	e.SetRenderer(&EchoRenderer{})

	e.GET("/static*", RenderStatic)

	return nil
}
开发者ID:boundedinfinity,项目名称:bi-echo,代码行数:9,代码来源:renderers.go



注:本文中的github.com/labstack/echo.Echo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang echo.Group类代码示例发布时间:2022-05-23
下一篇:
Golang echo.Context类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap