mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Update README.md
This commit is contained in:
parent
055200818a
commit
e5bdceae6a
27
README.md
27
README.md
@ -109,23 +109,24 @@ func main() {
|
|||||||
e.Get("/users", getUsers)
|
e.Get("/users", getUsers)
|
||||||
e.Get("/users/:id", getUser)
|
e.Get("/users/:id", getUser)
|
||||||
|
|
||||||
//****************//
|
//***********//
|
||||||
// Sub router //
|
// Group //
|
||||||
//****************//
|
//***********//
|
||||||
// Sub - inherits parent middleware
|
// Group with parent middleware
|
||||||
sub := e.Sub("/sub")
|
a := e.Group("/admin")
|
||||||
sub.Use(func(c *echo.Context) { // Middleware
|
a.Use(func(c *echo.Context) {
|
||||||
|
// Security middleware
|
||||||
})
|
})
|
||||||
sub.Get("/home", func(c *echo.Context) {
|
a.Get("", func(c *echo.Context) {
|
||||||
c.String(http.StatusOK, "Sub route /sub/welcome")
|
c.String(http.StatusOK, "Welcome admin!")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Group - doesn't inherit parent middleware
|
// Group with no parent middleware
|
||||||
grp := e.Group("/group")
|
g := e.Group("/files", func(c *echo.Context) {
|
||||||
grp.Use(func(c *echo.Context) { // Middleware
|
// Security middleware
|
||||||
})
|
})
|
||||||
grp.Get("/home", func(c *echo.Context) {
|
g.Get("", func(c *echo.Context) {
|
||||||
c.String(http.StatusOK, "Group route /group/welcome")
|
c.String(http.StatusOK, "Your files!")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
|
Loading…
Reference in New Issue
Block a user