Context File and FileFromFS examples at README

This commit is contained in:
nikandfor 2019-10-28 14:15:47 +03:00
parent 96cbedb140
commit 3582edb403
No known key found for this signature in database
GPG Key ID: 817D3804F9C0F547

View File

@ -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