Move auth HTTP header field regexp to a package level variable

This commit is contained in:
Pavel Korotkov 2020-07-21 11:35:30 +03:00
parent 3355a54272
commit e4f7a702dc

View file

@ -26,7 +26,7 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
) )
const authorizationFieldPattern = `AWS4-HMAC-SHA256 Credential=(?P<access_key_id>[^/]+)/(?P<date>[^/]+)/(?P<region>[^/]*)/(?P<service>[^/]+)/aws4_request, SignedHeaders=(?P<signed_header_fields>.*), Signature=(?P<v4_signature>.*)` var authorizationFieldRegexp = regexp.MustCompile(`AWS4-HMAC-SHA256 Credential=(?P<access_key_id>[^/]+)/(?P<date>[^/]+)/(?P<region>[^/]*)/(?P<service>[^/]+)/aws4_request, SignedHeaders=(?P<signed_header_fields>.*), Signature=(?P<v4_signature>.*)`)
const emptyStringSHA256 = `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855` const emptyStringSHA256 = `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`
@ -54,7 +54,7 @@ func NewCenter(log *zap.Logger) *Center {
zstdDecoder, _ := zstd.NewReader(nil) zstdDecoder, _ := zstd.NewReader(nil)
return &Center{ return &Center{
log: log, log: log,
submatcher: &regexpSubmatcher{re: regexp.MustCompile(authorizationFieldPattern)}, submatcher: &regexpSubmatcher{re: authorizationFieldRegexp},
zstdEncoder: zstdEncoder, zstdEncoder: zstdEncoder,
zstdDecoder: zstdDecoder, zstdDecoder: zstdDecoder,
} }