From 7d8cdf904069d011bf8b8f908fbc5190ed58b175 Mon Sep 17 00:00:00 2001 From: stuioco Date: Sat, 20 Jul 2024 10:39:33 +0100 Subject: [PATCH] changed template function setstatuscode to accept strings instead of int --- core/templating/template_helpers.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/templating/template_helpers.go b/core/templating/template_helpers.go index 6dd9df1bf..c73e274ff 100644 --- a/core/templating/template_helpers.go +++ b/core/templating/template_helpers.go @@ -2,13 +2,14 @@ package templating import ( "fmt" - "github.com/SpectoLabs/hoverfly/core/journal" "math" "reflect" "strconv" "strings" "time" + "github.com/SpectoLabs/hoverfly/core/journal" + "github.com/SpectoLabs/raymond" "github.com/pborman/uuid" @@ -187,9 +188,13 @@ func (t templateHelpers) hasJournalKey(indexName, keyValue string, options *raym return journalEntry != nil } -func (t templateHelpers) setStatusCode(statusCode int, options *raymond.Options) string { +func (t templateHelpers) setStatusCode(statusCode string, options *raymond.Options) string { + intStatusCode, err := strconv.Atoi(statusCode) + if err != nil { + return "" + } internalVars := options.ValueFromAllCtx("InternalVars").(map[string]interface{}) - internalVars["statusCode"] = statusCode + internalVars["statusCode"] = intStatusCode return "" }