1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

Changed example to reflect new name

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-03-27 14:49:45 -07:00
parent ff479f2fa0
commit d707f2cf04
2 changed files with 22 additions and 22 deletions

View File

@ -63,42 +63,42 @@ func getUser(c *echo.Context) {
} }
func main() { func main() {
b := echo.New() e := echo.New()
//*************************// //*************************//
// Built-in middleware // // Built-in middleware //
//*************************// //*************************//
b.Use(mw.Logger) e.Use(mw.Logger)
//****************************// //****************************//
// Third-party middleware // // Third-party middleware //
//****************************// //****************************//
// https://github.com/rs/cors // https://github.com/rs/cors
b.Use(cors.Default().Handler) e.Use(cors.Default().Handler)
// https://github.com/thoas/stats // https://github.com/thoas/stats
s := stats.New() s := stats.New()
b.Use(s.Handler) e.Use(s.Handler)
// Route // Route
b.Get("/stats", func(c *echo.Context) { e.Get("/stats", func(c *echo.Context) {
c.JSON(200, s.Data()) c.JSON(200, s.Data())
}) })
// Serve index file // Serve index file
b.Index("public/index.html") e.Index("public/index.html")
// Serve static files // Serve static files
b.Static("/js", "public/js") e.Static("/js", "public/js")
//************// //************//
// Routes // // Routes //
//************// //************//
b.Post("/users", createUser) e.Post("/users", createUser)
b.Get("/users", getUsers) e.Get("/users", getUsers)
b.Get("/users/:id", getUser) e.Get("/users/:id", getUser)
// Start server // Start server
b.Run(":8080") e.Run(":8080")
} }
``` ```

View File

@ -42,40 +42,40 @@ func getUser(c *echo.Context) {
} }
func main() { func main() {
b := echo.New() e := echo.New()
//*************************// //*************************//
// Built-in middleware // // Built-in middleware //
//*************************// //*************************//
b.Use(mw.Logger) e.Use(mw.Logger)
//****************************// //****************************//
// Third-party middleware // // Third-party middleware //
//****************************// //****************************//
// https://github.com/rs/cors // https://github.com/rs/cors
b.Use(cors.Default().Handler) e.Use(cors.Default().Handler)
// https://github.com/thoas/stats // https://github.com/thoas/stats
s := stats.New() s := stats.New()
b.Use(s.Handler) e.Use(s.Handler)
// Route // Route
b.Get("/stats", func(c *echo.Context) { e.Get("/stats", func(c *echo.Context) {
c.JSON(200, s.Data()) c.JSON(200, s.Data())
}) })
// Serve index file // Serve index file
b.Index("public/index.html") e.Index("public/index.html")
// Serve static files // Serve static files
b.Static("/js", "public/js") e.Static("/js", "public/js")
//************// //************//
// Routes // // Routes //
//************// //************//
b.Post("/users", createUser) e.Post("/users", createUser)
b.Get("/users", getUsers) e.Get("/users", getUsers)
b.Get("/users/:id", getUser) e.Get("/users/:id", getUser)
// Start server // Start server
b.Run(":8080") e.Run(":8080")
} }