Documentation ¶
Index ¶
- Constants
- func DoubleWildcardReplacementRegex(disallowColonInWildcardPathSegment bool) string
- func SingleWildcardReplacementRegex(disallowColonInWildcardPathSegment bool) string
- func Sort(methods *MethodSlice) error
- type Method
- type MethodSlice
- type Pattern
- type UriTemplate
- func (u *UriTemplate) Equal(v *UriTemplate) bool
- func (u *UriTemplate) ExactMatchString(acceptTrailingBackslash bool) string
- func (u *UriTemplate) IsExactMatch() bool
- func (u *UriTemplate) IsGRPCPathForOperation(selector string) (bool, error)
- func (u *UriTemplate) Regex(disallowColonInWildcardPathSegment bool) string
- func (u *UriTemplate) ReplaceVariableField(fieldMapping map[string]string)
- func (u *UriTemplate) String() string
Constants ¶
const ( // The special segment keys during uri template parsing. SingleParameterKey = "/." SingleWildCardKey = "*" DoubleWildCardKey = "**" HttpMethodWildCard = "*" )
const (
InvalidChar = byte(0)
)
Use null char to denote coming into invalid char.
Variables ¶
This section is empty.
Functions ¶
func DoubleWildcardReplacementRegex ¶
DoubleWildcardReplacementRegex does wildcard segment matching any char 0 or unlimited times, except '/'. If disallowColonInWildcardPathSegment=true, it matches any char except '/' and ':'.
func SingleWildcardReplacementRegex ¶
SingleWildcardReplacementRegex does wildcard segment matching any char 1 or unlimited times, except '/'. If disallowColonInWildcardPathSegment=true, it matches any char except '/' and ':'.
func Sort ¶
func Sort(methods *MethodSlice) error
Sort the slice of methods, based on the http patterns. It will raise errors:
- methods with duplicate http pattern
- invalid uri template
The time complexity is O(W * L), where W is the size of slice and L is the size of uri template segments
Types ¶
type MethodSlice ¶
type MethodSlice []*Method
func (*MethodSlice) AppendMethod ¶
func (sr *MethodSlice) AppendMethod(m *Method)
type Pattern ¶
type Pattern struct { HttpMethod string *UriTemplate }
Pattern Corresponds espv2.api.envoy.v12.http.common.Pattern and it holds the syntax parsing result for uri template.
type UriTemplate ¶
type UriTemplate struct { Segments []string Verb string Variables []*variable // The original uri template string before parsing. // It is ignored when calling `String` or `Equal` Origin string }
UriTemplate keeps information of the uri template string. It follows the grammar: https://github.com/googleapis/googleapis/blob/e5211c547d63632963f9125e2b333185d57ff8f6/google/api/http.proto#L224.
func ParseUriTemplate ¶
func ParseUriTemplate(input string) (*UriTemplate, error)
func (*UriTemplate) Equal ¶
func (u *UriTemplate) Equal(v *UriTemplate) bool
Check if two uriTemplates are equal. Ignore `Origin`
func (*UriTemplate) ExactMatchString ¶
func (u *UriTemplate) ExactMatchString(acceptTrailingBackslash bool) string
func (*UriTemplate) IsExactMatch ¶
func (u *UriTemplate) IsExactMatch() bool
func (*UriTemplate) IsGRPCPathForOperation ¶
func (u *UriTemplate) IsGRPCPathForOperation(selector string) (bool, error)
func (*UriTemplate) Regex ¶
func (u *UriTemplate) Regex(disallowColonInWildcardPathSegment bool) string
Generate regular expression of the current uri template.
func (*UriTemplate) ReplaceVariableField ¶
func (u *UriTemplate) ReplaceVariableField(fieldMapping map[string]string)
Replace all the variable fields found in the input map.
func (*UriTemplate) String ¶
func (u *UriTemplate) String() string
Output the string representation with defaults.