mirror of
https://github.com/labstack/echo.git
synced 2025-01-12 01:22:21 +02:00
Updated docs
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
fcbdaae620
commit
ace1453931
@ -162,24 +162,33 @@ e.Get("/users/:id", h)
|
|||||||
|
|
||||||
### JSON
|
### JSON
|
||||||
|
|
||||||
`context.JSON(code int, v interface{}) error` can be used to send a JSON response
|
```go
|
||||||
with status code.
|
context.JSON(code int, v interface{}) error
|
||||||
|
```
|
||||||
|
|
||||||
|
Sends a JSON response with status code.
|
||||||
|
|
||||||
### String
|
### String
|
||||||
|
|
||||||
`context.String(code int, s string) error` can be used to send a text/plain response
|
```go
|
||||||
with status code.
|
context.String(code int, s string) error
|
||||||
|
```
|
||||||
|
|
||||||
|
Sends a text/plain response with status code.
|
||||||
|
|
||||||
### HTML
|
### HTML
|
||||||
|
|
||||||
`func (c *Context) HTML(code int, html string) error` can be used to send an HTML
|
```go
|
||||||
response with status code.
|
func (c *Context) HTML(code int, html string) error
|
||||||
|
```
|
||||||
|
|
||||||
|
Sends an HTML response with status code.
|
||||||
|
|
||||||
### Static files
|
### Static files
|
||||||
|
|
||||||
`echo.Static(path, root string)` can be used to serve static files. For example,
|
`echo.Static(path, root string)` serves static files. For example, code below
|
||||||
code below serves all files from `public/scripts` directory for any path starting
|
serves all files from `public/scripts` directory for any path starting
|
||||||
with `/scripts/`.
|
with `/scripts/`
|
||||||
|
|
||||||
```go
|
```go
|
||||||
e.Static("/scripts", "public/scripts")
|
e.Static("/scripts", "public/scripts")
|
||||||
@ -187,8 +196,8 @@ e.Static("/scripts", "public/scripts")
|
|||||||
|
|
||||||
### Serving a file
|
### Serving a file
|
||||||
|
|
||||||
`echo.ServeFile(path, file string)` can be used to serve a file. For example, code
|
`echo.ServeFile(path, file string)` serves a file. For example, code below serves
|
||||||
below serves welcome.html for path `/welcome`.
|
welcome.html for path `/welcome`
|
||||||
|
|
||||||
```go
|
```go
|
||||||
e.ServeFile("/welcome", "welcome.html")
|
e.ServeFile("/welcome", "welcome.html")
|
||||||
@ -196,8 +205,8 @@ e.ServeFile("/welcome", "welcome.html")
|
|||||||
|
|
||||||
### Serving an index file
|
### Serving an index file
|
||||||
|
|
||||||
`echo.Index(file string)` can be used to serve index file. For example, code below
|
`echo.Index(file string)` serves an index file. For example, code below serves
|
||||||
serves index.html for path `/`.
|
index.html for path `/`
|
||||||
|
|
||||||
```go
|
```go
|
||||||
e.Index("index.html")
|
e.Index("index.html")
|
||||||
|
Loading…
Reference in New Issue
Block a user