mirror of
https://github.com/kataras/iris.git
synced 2025-01-24 03:01:03 +01:00
0d26f24eb7
Former-commit-id: d20afb2e899aee658a8e0ed1693357798df93462
22 lines
634 B
Go
22 lines
634 B
Go
package main
|
|
|
|
import "github.com/kataras/iris/v12"
|
|
|
|
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.Listen(":8080")
|
|
}
|