mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-20 00:02:16 +08:00
Context File and FileFromFS examples at README
This commit is contained in:
parent
96cbedb140
commit
3582edb403
18
README.md
18
README.md
@ -1212,6 +1212,24 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Serving data from file
|
||||||
|
|
||||||
|
```go
|
||||||
|
func main() {
|
||||||
|
router := gin.Default()
|
||||||
|
|
||||||
|
router.GET("/local/file", func(c *gin.Context) {
|
||||||
|
c.File("local/file.go")
|
||||||
|
})
|
||||||
|
|
||||||
|
var fs http.FileSystem = // ...
|
||||||
|
router.GET("/fs/file", func(c *gin.Context) {
|
||||||
|
c.FileFromFS("fs/file.go", fs)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
### Serving data from reader
|
### Serving data from reader
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
Loading…
x
Reference in New Issue
Block a user