examples icon indicating copy to clipboard operation
examples copied to clipboard

body is null in LoggerWithFormatter

Open dasuma opened this issue 3 years ago • 0 comments

i have a problems when i try loggin del body because de body is null

gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
	
		body, err := ioutil.ReadAll(param.Request.Body)

the problem is in my controller i have this code

	var body entities.WriteChatRequest
	if err := c.ShouldBindJSON(&body); err != nil {
		c.JSON(400, gin.H{"error": err.Error()})
		return
	}

the body was converted but now is null, when the controller finished and i try logging

dasuma avatar Feb 07 '22 18:02 dasuma