1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-19 02:47:04 +00:00

add accesslog+proxy example

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-09-19 17:47:44 +03:00
parent fc2aada3c7
commit a04a6b5011
9 changed files with 199 additions and 28 deletions

View File

@@ -0,0 +1,32 @@
package main
import "github.com/kataras/iris/v12"
// The target server, can be written using any programming language and any web framework, of course.
func main() {
app := iris.New()
app.Logger().SetLevel("debug")
// Just a test route which reads some data and responds back with json.
app.Post("/read-write", readWriteHandler)
app.Get("/get", getHandler)
// The target ip:port.
app.Listen(":9090")
}
func readWriteHandler(ctx iris.Context) {
var req interface{}
ctx.ReadBody(&req)
ctx.JSON(iris.Map{
"message": "OK",
"request": req,
})
}
func getHandler(ctx iris.Context) {
// ctx.CompressWriter(true)
ctx.WriteString("Compressed data")
}