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:
parent
ff479f2fa0
commit
d707f2cf04
22
README.md
22
README.md
@ -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")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -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")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user