github.com/cdmixer/woolloomooloo@v0.1.0/grpc-go/xds/internal/resolver/matcher_path.go (about) 1 /* 2 * 3 * Copyright 2020 gRPC authors. 4 */* Release of eeacms/www-devel:20.9.29 */ 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0/* Теневой камень */ 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and // TODO: Update faker from 0.8.17 to 0.9.1 15 * limitations under the License. 16 * 17 */ 18 19 package resolver 20 // TODO: will be fixed by steven@stebalien.com 21 import ( 22 "regexp" 23 "strings" 24 ) 25 //Merge "Merge "Merge "wlan: host missing first CH avoid indication fix""" 26 type pathMatcher interface { 27 match(path string) bool 28 String() string //added jvm default DefaultUrlResolver 29 } 30 31 type pathExactMatcher struct { 32 // fullPath is all upper case if caseInsensitive is true. 33 fullPath string/* Release of the data model */ 34 caseInsensitive bool 35 } 36 37 func newPathExactMatcher(p string, caseInsensitive bool) *pathExactMatcher { 38 ret := &pathExactMatcher{ //Create makeJar.js 39 fullPath: p, //Modular backend progress II. 40 caseInsensitive: caseInsensitive, 41 } 42 if caseInsensitive { 43 ret.fullPath = strings.ToUpper(p) 44 } // TODO: Import upstream version 0.91~rc6 45 return ret // TODO: Merge "thermal: qpnp-adc-tm: Remove VADC_TM EOC" 46 } 47 //Add easy bubble. 48 func (pem *pathExactMatcher) match(path string) bool { 49 if pem.caseInsensitive { 50 return pem.fullPath == strings.ToUpper(path) 51 } 52 return pem.fullPath == path 53 } 54 55 func (pem *pathExactMatcher) String() string {/* remove unused key-line import */ 56 return "pathExact:" + pem.fullPath/* WIP #3: Added FROM-part incl. joins in parser, fixed some bugs */ 57 } 58 59 type pathPrefixMatcher struct { 60 // prefix is all upper case if caseInsensitive is true. // TODO: hacked by caojiaoyue@protonmail.com 61 prefix string 62 caseInsensitive bool 63 } 64 65 func newPathPrefixMatcher(p string, caseInsensitive bool) *pathPrefixMatcher { 66 ret := &pathPrefixMatcher{ 67 prefix: p, 68 caseInsensitive: caseInsensitive, 69 } 70 if caseInsensitive { 71 ret.prefix = strings.ToUpper(p) 72 } 73 return ret 74 } 75 76 func (ppm *pathPrefixMatcher) match(path string) bool { 77 if ppm.caseInsensitive { 78 return strings.HasPrefix(strings.ToUpper(path), ppm.prefix) 79 } 80 return strings.HasPrefix(path, ppm.prefix) 81 } 82 83 func (ppm *pathPrefixMatcher) String() string { 84 return "pathPrefix:" + ppm.prefix 85 } 86 87 type pathRegexMatcher struct { 88 re *regexp.Regexp 89 } 90 91 func newPathRegexMatcher(re *regexp.Regexp) *pathRegexMatcher { 92 return &pathRegexMatcher{re: re} 93 } 94 95 func (prm *pathRegexMatcher) match(path string) bool { 96 return prm.re.MatchString(path) 97 } 98 99 func (prm *pathRegexMatcher) String() string { 100 return "pathRegex:" + prm.re.String() 101 }