forked from kataras/iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example for the simple context#WriteGzip
- Loading branch information
Showing
3 changed files
with
29 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import "github.com/kataras/iris" | ||
|
||
func main() { | ||
app := iris.New() | ||
app.Get("/", func(ctx iris.Context) { | ||
ctx.WriteGzip([]byte("Hello World!")) | ||
ctx.Header("X-Custom", | ||
"Headers can be set here after WriteGzip as well, because the data are kept before sent to the client when using the context's GzipResponseWriter and ResponseRecorder.") | ||
}) | ||
|
||
app.Get("/2", func(ctx iris.Context) { | ||
// same as the `WriteGzip`. | ||
// However GzipResponseWriter gives you more options, like | ||
// reset data, disable and more, look its methods. | ||
ctx.GzipResponseWriter().WriteString("Hello World!") | ||
}) | ||
|
||
app.Run(iris.Addr(":8080")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters