luraproject / lura

Regular expression can be simplified GO-C4007
Style
Minor
6 months ago2 years old
can re-write \{\{\.Resp(\d+)_([\w-\.]+)\}\} as \{\{\.Resp(\d+)_([\w-.]+)\}\}
118	}
119}
120
121var reMergeKey = regexp.MustCompile(`\{\{\.Resp(\d+)_([\w-\.]+)\}\}`)122
123func sequentialMerge(reqCloner func(*Request) *Request, patterns []string, timeout time.Duration, rc ResponseCombiner, next ...Proxy) Proxy {
124	return func(ctx context.Context, request *Request) (*Response, error) {
can re-write ^(resp[\d]+_.+)?(JWT\.([\w\-\.:/]+))?$ as ^(resp\d+_.+)?(JWT\.([\w\-.:/]+))?$
366
367var (
368	simpleURLKeysPattern    = regexp.MustCompile(`\{([\w\-\.:/]+)\}`)
369	sequentialParamsPattern = regexp.MustCompile(`^(resp[\d]+_.+)?(JWT\.([\w\-\.:/]+))?$`)370	invalidPattern          = `^[^/]|\*.|/__(debug|echo|health)(/.*)?$`
371	errInvalidHost          = errors.New("invalid host")
372	errInvalidNoOpEncoding  = errors.New("can not use NoOp encoding with more than one backends connected to the same endpoint")
can re-write \{([\w\-\.:/]+)\} as \{([\w\-.:/]+)\}
365var ExtraConfigAlias = map[string]string{}
366
367var (
368	simpleURLKeysPattern    = regexp.MustCompile(`\{([\w\-\.:/]+)\}`)369	sequentialParamsPattern = regexp.MustCompile(`^(resp[\d]+_.+)?(JWT\.([\w\-\.:/]+))?$`)
370	invalidPattern          = `^[^/]|\*.|/__(debug|echo|health)(/.*)?$`
371	errInvalidHost          = errors.New("invalid host")
can re-write (https?://)?([a-zA-Z0-9\._\-]+)(:[0-9]{2,6})?/? as (https?://)?([a-zA-Z0-9._\-]+)(:\d{2,6})?/?
 10
 11var (
 12	endpointURLKeysPattern = regexp.MustCompile(`/\{([a-zA-Z\-_0-9]+)\}`)
 13	hostPattern            = regexp.MustCompile(`(https?://)?([a-zA-Z0-9\._\-]+)(:[0-9]{2,6})?/?`) 14)
 15
 16// URIParser defines the interface for all the URI manipulation required by KrakenD