mirror of
https://github.com/kataras/iris.git
synced 2025-12-23 12:57:05 +00:00
(#1554) Add support for all common compressions (write and read)
- Remove the context.Context interface and export the *context, the iris.Context now points to the pointer\nSupport compression and rate limiting in the FileServer\nBit of code organisation Former-commit-id: ad1c61bf968059510c6be9e7f2cceec7da70ba17
This commit is contained in:
@@ -17,7 +17,7 @@ func main() {
|
||||
app := iris.New()
|
||||
|
||||
app.Get("/users", func(ctx iris.Context) {
|
||||
ctx.Gzip(true)
|
||||
ctx.Compress(true)
|
||||
ctx.ContentType("text/html")
|
||||
|
||||
userList := []string{
|
||||
@@ -35,11 +35,9 @@ func main() {
|
||||
// template.UserList(userList, buffer)
|
||||
// ctx.Write(buffer.Bytes())
|
||||
|
||||
// using an io.Writer for automatic buffer management (i.e. hero built-in buffer pool),
|
||||
// iris context implements the io.Writer by its ResponseWriter
|
||||
// which is an enhanced version of the standard http.ResponseWriter
|
||||
// but still 100% compatible, GzipResponseWriter too:
|
||||
// _, err := template.UserListToWriter(userList, ctx.GzipResponseWriter())
|
||||
// iris context implements the io.Writer:
|
||||
// _, err := template.UserListToWriter(userList, ctx)
|
||||
// OR:
|
||||
buffer := new(bytes.Buffer)
|
||||
template.UserList(userList, buffer)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user