From bad7eebd36564567345b76ef76820fabda32ec5d Mon Sep 17 00:00:00 2001 From: Damian Bednarczyk Date: Mon, 6 Nov 2023 15:29:20 -0600 Subject: [PATCH] fix: preallocate headers array --- handlers/api.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/handlers/api.go b/handlers/api.go index 28e0346..e8a7611 100644 --- a/handlers/api.go +++ b/handlers/api.go @@ -27,7 +27,8 @@ func Api(c *fiber.Ctx) error { Version: version, Body: body, } - response.Request.Headers = make([]interface{}, 0) + + response.Request.Headers = make([]any, 0, len(req.Header)) for k, v := range req.Header { response.Request.Headers = append(response.Request.Headers, map[string]string{ "key": k, @@ -35,7 +36,7 @@ func Api(c *fiber.Ctx) error { }) } - response.Response.Headers = make([]interface{}, 0) + response.Response.Headers = make([]any, 0, len(resp.Header)) for k, v := range resp.Header { response.Response.Headers = append(response.Response.Headers, map[string]string{ "key": k,