mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Updated docs
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
f80fff4efb
commit
bd0c177d5e
@ -63,8 +63,8 @@ below registers a route for method `GET`, path `/hello` and a handler which send
|
|||||||
`Hello!` response.
|
`Hello!` response.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
echo.Get("/hello", func(*echo.Context) {
|
echo.Get("/hello", func(*echo.Context) *HTTPError {
|
||||||
c.String(http.StatusOK, "Hello!")
|
return c.String(http.StatusOK, "Hello!")
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -83,14 +83,14 @@ index `echo.Context.P(i uint8) string`. Getting parameter by index gives a sligh
|
|||||||
better performance.
|
better performance.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
echo.Get("/users/:id", func(c *echo.Context) {
|
echo.Get("/users/:id", func(c *echo.Context) *HTTPError {
|
||||||
// By name
|
// By name
|
||||||
id := c.Param("id")
|
id := c.Param("id")
|
||||||
|
|
||||||
// By index
|
// By index
|
||||||
id := c.P(0)
|
id := c.P(0)
|
||||||
|
|
||||||
c.String(http.StatusOK, id)
|
return c.String(http.StatusOK, id)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -113,16 +113,16 @@ match
|
|||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```go
|
```go
|
||||||
e.Get("/users/:id", func(c *echo.Context) {
|
e.Get("/users/:id", func(c *echo.Context) *HTTPError {
|
||||||
c.String(http.StatusOK, "/users/:id")
|
return c.String(http.StatusOK, "/users/:id")
|
||||||
})
|
})
|
||||||
|
|
||||||
e.Get("/users/new", func(c *echo.Context) {
|
e.Get("/users/new", func(c *echo.Context) *HTTPError {
|
||||||
c.String(http.StatusOK, "/users/new")
|
return c.String(http.StatusOK, "/users/new")
|
||||||
})
|
})
|
||||||
|
|
||||||
e.Get("/users/1/files/*", func(c *echo.Context) {
|
e.Get("/users/1/files/*", func(c *echo.Context) *HTTPError {
|
||||||
c.String(http.StatusOK, "/users/1/files/*")
|
return c.String(http.StatusOK, "/users/1/files/*")
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -146,8 +146,8 @@ application.
|
|||||||
|
|
||||||
```go
|
```go
|
||||||
// Handler
|
// Handler
|
||||||
h := func(*echo.Context) {
|
h := func(*echo.Context) *HTTPError {
|
||||||
c.String(http.StatusOK, "OK")
|
return c.String(http.StatusOK, "OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route
|
// Route
|
||||||
@ -161,7 +161,7 @@ e.Get("/users/:id", h)
|
|||||||
### JSON
|
### JSON
|
||||||
|
|
||||||
```go
|
```go
|
||||||
context.JSON(code int, v interface{}) error
|
context.JSON(code int, v interface{}) *HTTPError
|
||||||
```
|
```
|
||||||
|
|
||||||
Sends a JSON response with status code.
|
Sends a JSON response with status code.
|
||||||
@ -169,7 +169,7 @@ Sends a JSON response with status code.
|
|||||||
### String
|
### String
|
||||||
|
|
||||||
```go
|
```go
|
||||||
context.String(code int, s string) error
|
context.String(code int, s string) *HTTPError
|
||||||
```
|
```
|
||||||
|
|
||||||
Sends a text/plain response with status code.
|
Sends a text/plain response with status code.
|
||||||
@ -177,7 +177,7 @@ Sends a text/plain response with status code.
|
|||||||
### HTML
|
### HTML
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func (c *Context) HTML(code int, html string) error
|
func (c *Context) HTML(code int, html string) *HTTPError
|
||||||
```
|
```
|
||||||
|
|
||||||
Sends an HTML response with status code.
|
Sends an HTML response with status code.
|
||||||
|
Loading…
Reference in New Issue
Block a user