From b8e057ac510a2404c4298410920b3bf506fbc3c0 Mon Sep 17 00:00:00 2001 From: Ryan Jeynes Date: Tue, 3 Mar 2020 16:31:40 +0000 Subject: [PATCH] Moved the c.Next() function call before Status() in order to get the correct response code, otherwise it defualts to 200. --- middleware.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/middleware.go b/middleware.go index fb5e5b3..0080daf 100644 --- a/middleware.go +++ b/middleware.go @@ -68,9 +68,10 @@ func (g *GinInflux) write(bp *client.Point) { func (g *GinInflux) HandlerFunc() gin.HandlerFunc { return func(c *gin.Context) { start := time.Now() - status := strconv.Itoa(c.Writer.Status()) c.Next() + + status := strconv.Itoa(c.Writer.Status()) elapsed := float64(time.Since(start)) / float64(time.Second) go func() {