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
1b757d99d8
commit
8bdbf0ae0f
@ -65,8 +65,8 @@ data structure which makes routing lookup really fast. It leverages
|
||||
[sync pool](https://golang.org/pkg/sync/#Pool) to reuse memory and achieve
|
||||
zero dynamic memory allocation with no GC overhead.
|
||||
|
||||
Routes can be registered for any HTTP method, path and handler. For example, code
|
||||
below registers a route for method `GET`, path `/hello` and a handler which sends
|
||||
Routes can be registered by specifying HTTP method, path and a handler. For example,
|
||||
code below registers a route for method `GET`, path `/hello` and a handler which sends
|
||||
`Hello!` HTTP response.
|
||||
|
||||
```go
|
||||
@ -87,9 +87,9 @@ types of handlers.
|
||||
|
||||
### Path parameter
|
||||
|
||||
URL path parameters can be extracted either by name `echo.Context.Param(name string) string` or by
|
||||
index `echo.Context.P(i uint8) string`. Getting parameter by index gives a slightly
|
||||
better performance.
|
||||
URL path parameters can be extracted either by name `echo.Context.Param(name string) string`
|
||||
or by index `echo.Context.P(i uint8) string`. Getting parameter by index gives a
|
||||
slightly better performance.
|
||||
|
||||
```go
|
||||
echo.Get("/users/:id", func(c *echo.Context) *HTTPError {
|
||||
|
@ -89,8 +89,8 @@ made to the server, producing output
|
||||
2015/04/25 12:15:29 GET / 200 5.434µs
|
||||
```
|
||||
|
||||
`e.Get("/", hello)` Registers a GET route for path `/` with hello handler, so
|
||||
whenever server receives an HTTP request at `/`, hello handler is called.
|
||||
`e.Get("/", hello)` Registers hello handler for HTTP method `GET` and path `/`, so
|
||||
whenever server receives an HTTP request at `/`, hello function is called.
|
||||
|
||||
In hello handler `c.String(http.StatusOK, "Hello, World!\n")` sends a text/plain
|
||||
HTTP response to the client with 200 status code.
|
||||
|
Loading…
Reference in New Issue
Block a user