kataras / kataras/iris

[BUG] accesslog: BodyMinify = true && ResponseBody = true will be change response json value

Open
#1,745 1 comment 0 reactions 1 assignee Claimed by @kataras View on GitHub
🐞 type:bug
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
accesslog: BodyMinify = true && ResponseBody = true will be change response json value

**To Reproduce**
Steps to reproduce the behavior:
```
package main

import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/accesslog"
)

// Read the example and its comments carefully.
func makeAccessLog() *accesslog.AccessLog {
// Initialize a new access log middleware.
ac := accesslog.File("./access.log")

ac.BodyMinify = true
ac.ResponseBody = true

return ac
}

func main() {
ac := makeAccessLog()
defer ac.Close() // Close the underline file.

app := iris.New()
// Register the middleware (UseRouter to catch http errors too).
app.UseRouter(ac.Handler)

app.Get("/", indexHandler)

app.Listen(":8080")
}

func indexHandler(ctx iris.Context) {
ctx.JSON(map[string]int{"Num": 1000})
}

```

**Expected behavior**
> {"Num": 1000}

**Screenshots**
> {"Num": 1e30}

**Desktop (please complete the following information):**
- OS: macos

**iris.Version**
- v12.2.0-alpha2

**Additional context**
Is the minify features
https://github.com/tdewolff/minify/issues/386

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.