@@ -34,16 +34,16 @@ const (
34
34
35
35
responseOK = `{"text": "Success", "code": 0}`
36
36
responseHecHealthy = `{"text": "HEC is healthy", "code": 17}`
37
- responseInvalidMethod = `Only "POST" method is supported`
38
- responseInvalidEncoding = `"Content-Encoding" must be "gzip" or empty`
37
+ responseInvalidMethod = `" Only \ "POST\ " method is supported" `
38
+ responseInvalidEncoding = `"\" Content-Encoding\ " must be \ "gzip\ " or empty" `
39
39
responseInvalidDataFormat = `{"text":"Invalid data format","code":6}`
40
40
responseErrEventRequired = `{"text":"Event field is required","code":12}`
41
41
responseErrEventBlank = `{"text":"Event field cannot be blank","code":13}`
42
- responseErrGzipReader = "Error on gzip body"
43
- responseErrUnmarshalBody = "Failed to unmarshal message body"
44
- responseErrInternalServerError = "Internal Server Error"
45
- responseErrUnsupportedMetricEvent = "Unsupported metric event"
46
- responseErrUnsupportedLogEvent = "Unsupported log event"
42
+ responseErrGzipReader = ` "Error on gzip body"`
43
+ responseErrUnmarshalBody = ` "Failed to unmarshal message body"`
44
+ responseErrInternalServerError = ` "Internal Server Error"`
45
+ responseErrUnsupportedMetricEvent = ` "Unsupported metric event"`
46
+ responseErrUnsupportedLogEvent = ` "Unsupported log event"`
47
47
responseErrHandlingIndexedFields = `{"text":"Error in handling indexed fields","code":15,"invalid-event-number":%d}`
48
48
responseNoData = `{"text":"No data","code":5}`
49
49
// Centralizing some HTTP and related string constants.
@@ -58,18 +58,18 @@ var (
58
58
errInvalidMethod = errors .New ("invalid http method" )
59
59
errInvalidEncoding = errors .New ("invalid encoding" )
60
60
61
- okRespBody = initJSONResponse (responseOK )
62
- eventRequiredRespBody = initJSONResponse (responseErrEventRequired )
63
- eventBlankRespBody = initJSONResponse (responseErrEventBlank )
64
- invalidEncodingRespBody = initJSONResponse (responseInvalidEncoding )
65
- invalidFormatRespBody = initJSONResponse (responseInvalidDataFormat )
66
- invalidMethodRespBody = initJSONResponse (responseInvalidMethod )
67
- errGzipReaderRespBody = initJSONResponse (responseErrGzipReader )
68
- errUnmarshalBodyRespBody = initJSONResponse (responseErrUnmarshalBody )
69
- errInternalServerError = initJSONResponse (responseErrInternalServerError )
70
- errUnsupportedMetricEvent = initJSONResponse (responseErrUnsupportedMetricEvent )
71
- errUnsupportedLogEvent = initJSONResponse (responseErrUnsupportedLogEvent )
72
- noDataRespBody = initJSONResponse (responseNoData )
61
+ okRespBody = [] byte (responseOK )
62
+ eventRequiredRespBody = [] byte (responseErrEventRequired )
63
+ eventBlankRespBody = [] byte (responseErrEventBlank )
64
+ invalidEncodingRespBody = [] byte (responseInvalidEncoding )
65
+ invalidFormatRespBody = [] byte (responseInvalidDataFormat )
66
+ invalidMethodRespBody = [] byte (responseInvalidMethod )
67
+ errGzipReaderRespBody = [] byte (responseErrGzipReader )
68
+ errUnmarshalBodyRespBody = [] byte (responseErrUnmarshalBody )
69
+ errInternalServerError = [] byte (responseErrInternalServerError )
70
+ errUnsupportedMetricEvent = [] byte (responseErrUnsupportedMetricEvent )
71
+ errUnsupportedLogEvent = [] byte (responseErrUnsupportedLogEvent )
72
+ noDataRespBody = [] byte (responseNoData )
73
73
)
74
74
75
75
// splunkReceiver implements the receiver.Metrics for Splunk HEC metric protocol.
@@ -464,15 +464,6 @@ func (r *splunkReceiver) handleHealthReq(writer http.ResponseWriter, _ *http.Req
464
464
_ , _ = writer .Write ([]byte (responseHecHealthy ))
465
465
}
466
466
467
- func initJSONResponse (s string ) []byte {
468
- respBody , err := jsoniter .Marshal (s )
469
- if err != nil {
470
- // This is to be used in initialization so panic here is fine.
471
- panic (err )
472
- }
473
- return respBody
474
- }
475
-
476
467
func isFlatJSONField (field interface {}) bool {
477
468
switch value := field .(type ) {
478
469
case map [string ]interface {}:
0 commit comments