From 7e35a6ebbdcbbb7cd6a4d1b6da8f1b667550bad3 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Tue, 17 Nov 2020 19:34:22 -0500 Subject: [PATCH] Rename PlaceHolder to Placeholder --- core/condition.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/condition.go b/core/condition.go index 36cc9bf3..1dac1410 100644 --- a/core/condition.go +++ b/core/condition.go @@ -17,25 +17,25 @@ const ( // Values that could replace the placeholder: 200, 404, 500, ... StatusPlaceholder = "[STATUS]" - // IPPlaceHolder is a placeholder for an IP. + // IPPlaceholder is a placeholder for an IP. // // Values that could replace the placeholder: 127.0.0.1, 10.0.0.1, ... - IPPlaceHolder = "[IP]" + IPPlaceholder = "[IP]" - // ResponseTimePlaceHolder is a placeholder for the request response time, in milliseconds. + // ResponseTimePlaceholder is a placeholder for the request response time, in milliseconds. // // Values that could replace the placeholder: 1, 500, 1000, ... - ResponseTimePlaceHolder = "[RESPONSE_TIME]" + ResponseTimePlaceholder = "[RESPONSE_TIME]" - // BodyPlaceHolder is a placeholder for the body of the response + // BodyPlaceholder is a placeholder for the body of the response // // Values that could replace the placeholder: {}, {"data":{"name":"john"}}, ... - BodyPlaceHolder = "[BODY]" + BodyPlaceholder = "[BODY]" - // ConnectedPlaceHolder is a placeholder for whether a connection was successfully established. + // ConnectedPlaceholder is a placeholder for whether a connection was successfully established. // // Values that could replace the placeholder: true, false - ConnectedPlaceHolder = "[CONNECTED]" + ConnectedPlaceholder = "[CONNECTED]" // CertificateExpirationPlaceholder is a placeholder for the duration before certificate expiration, in milliseconds. // @@ -141,25 +141,25 @@ func sanitizeAndResolve(list []string, result *Result) []string { switch strings.ToUpper(element) { case StatusPlaceholder: element = strconv.Itoa(result.HTTPStatus) - case IPPlaceHolder: + case IPPlaceholder: element = result.IP - case ResponseTimePlaceHolder: + case ResponseTimePlaceholder: element = strconv.Itoa(int(result.Duration.Milliseconds())) - case BodyPlaceHolder: + case BodyPlaceholder: element = body - case ConnectedPlaceHolder: + case ConnectedPlaceholder: element = strconv.FormatBool(result.Connected) case CertificateExpirationPlaceholder: - element = strconv.FormatInt(int64(result.CertificateExpiration.Milliseconds()), 10) + element = strconv.FormatInt(result.CertificateExpiration.Milliseconds(), 10) default: - // if contains the BodyPlaceHolder, then evaluate json path - if strings.Contains(element, BodyPlaceHolder) { + // if contains the BodyPlaceholder, then evaluate json path + if strings.Contains(element, BodyPlaceholder) { wantLength := false if strings.HasPrefix(element, LengthFunctionPrefix) && strings.HasSuffix(element, FunctionSuffix) { wantLength = true element = strings.TrimSuffix(strings.TrimPrefix(element, LengthFunctionPrefix), FunctionSuffix) } - resolvedElement, resolvedElementLength, err := jsonpath.Eval(strings.Replace(element, fmt.Sprintf("%s.", BodyPlaceHolder), "", 1), result.Body) + resolvedElement, resolvedElementLength, err := jsonpath.Eval(strings.Replace(element, fmt.Sprintf("%s.", BodyPlaceholder), "", 1), result.Body) if err != nil { if err.Error() != "unexpected end of JSON input" { result.Errors = append(result.Errors, err.Error())