mirror of
https://github.com/labstack/echo.git
synced 2025-02-03 13:11:39 +02:00
fixed docs
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
c5a3575d4c
commit
43e95a6924
49
echo.go
49
echo.go
@ -3,39 +3,36 @@ Package echo implements a fast and unfancy HTTP server framework for Go (Golang)
|
||||
|
||||
Example:
|
||||
|
||||
package main
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo"
|
||||
"github.com/labstack/echo/engine/standard"
|
||||
"github.com/labstack/echo/middleware"
|
||||
"net"
|
||||
"net"
|
||||
)
|
||||
"github.com/labstack/echo"
|
||||
"github.com/labstack/echo/middleware"
|
||||
)
|
||||
|
||||
// Handler
|
||||
func hello(c echo.Context) error {
|
||||
return c.String(http.StatusOK, "Hello, World!")
|
||||
}
|
||||
// Handler
|
||||
func hello(c echo.Context) error {
|
||||
return c.String(http.StatusOK, "Hello, World!")
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Echo instance
|
||||
e := echo.New()
|
||||
func main() {
|
||||
// Echo instance
|
||||
e := echo.New()
|
||||
|
||||
// Middleware
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Recover())
|
||||
// Middleware
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Recover())
|
||||
|
||||
// Routes
|
||||
e.GET("/", hello)
|
||||
// Routes
|
||||
e.GET("/", hello)
|
||||
|
||||
// Start server
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
// Start server
|
||||
if err := e.Start(":1323"); err != nil {
|
||||
e.Logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Learn more at https://echo.labstack.com
|
||||
*/
|
||||
|
@ -1,8 +0,0 @@
|
||||
+++
|
||||
title = "engine"
|
||||
[menu.side]
|
||||
name = "engine"
|
||||
parent = "godoc"
|
||||
weight = 3
|
||||
url = "https://godoc.org/github.com/labstack/echo/engine"
|
||||
+++
|
@ -1,8 +0,0 @@
|
||||
+++
|
||||
title = "fasthttp"
|
||||
[menu.side]
|
||||
name = "engine/fasthttp"
|
||||
parent = "godoc"
|
||||
weight = 5
|
||||
url = "https://godoc.org/github.com/labstack/echo/engine/fasthttp"
|
||||
+++
|
@ -4,6 +4,6 @@ title = "middleware"
|
||||
name = "middleware"
|
||||
identifier = "godoc-middleware"
|
||||
parent = "godoc"
|
||||
weight = 1
|
||||
weight = 2
|
||||
url = "https://godoc.org/github.com/labstack/echo/middleware"
|
||||
+++
|
||||
|
@ -1,8 +0,0 @@
|
||||
+++
|
||||
title = "standard"
|
||||
[menu.side]
|
||||
name = "engine/standard"
|
||||
parent = "godoc"
|
||||
weight = 4
|
||||
url = "https://godoc.org/github.com/labstack/echo/engine/standard"
|
||||
+++
|
@ -12,8 +12,8 @@ description = "Context in Echo"
|
||||
|
||||
`echo.Context` represents the context of the current HTTP request. It holds request and
|
||||
response reference, path, path parameters, data, registered handler and APIs to read
|
||||
request and write response. Context is 100% compatible with standard `context.Context`.
|
||||
As Context is an interface, it is easy to extend it with custom APIs.
|
||||
request and write response. As Context is an interface, it is easy to extend it with
|
||||
custom APIs.
|
||||
|
||||
#### Extending Context
|
||||
|
||||
@ -56,20 +56,3 @@ e.GET("/", func(c echo.Context) error {
|
||||
return cc.String(200, "OK")
|
||||
})
|
||||
```
|
||||
|
||||
### Standard Context
|
||||
|
||||
`echo.Context` embeds standard `context.Context` interface, so all it's functions
|
||||
are available right from `echo.Context`.
|
||||
|
||||
*Example*
|
||||
|
||||
```go
|
||||
e.GET("/users/:name", func(c echo.Context) error) {
|
||||
c.SetContext(context.WithValue(nil, "key", "val"))
|
||||
// Pass it down...
|
||||
// Use it...
|
||||
val := c.Value("key").(string)
|
||||
return c.String(http.StatusOK, name)
|
||||
})
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user