FileFromFS (#2112)

* Context.FileFromFS added

* Context File and FileFromFS examples at README

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Nikifor Seryakov
2020-03-07 05:23:33 +03:00
committed by GitHub
parent 2ff2b19e14
commit 1d055af1bc
3 changed files with 42 additions and 0 deletions

View File

@ -1182,6 +1182,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
```go