Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSegmentLengthMismatch = errors.New("resource name segment count does not match that of the pattern") ErrSegmentConstantMismatch = errors.New("a non-variable segment did not match constant pattern segment") ErrNotAStruct = errors.New("resource must be a pointer to a struct") ErrMissingSegment = errors.New("resource is missing variable segment") )
Functions ¶
This section is empty.
Types ¶
type NamePattern ¶
type NamePattern struct {
// contains filtered or unexported fields
}
Represents all segments of a resource name pattern. It is a template to parse resource names against and extract the values of variable segments.
func FromPattern ¶
func FromPattern(pattern string) NamePattern
FromPattern constructs a NamePattern from a given resource name pattern string. Given a pattern string like `/resource/{resource_id}`, it constructs a NamePattern consisting of the constant segment `resource` and the variable segment `resource_id`
func (NamePattern) Marshal ¶ added in v0.1.0
func (p NamePattern) Marshal(resource any) (string, error)
func (NamePattern) Parse ¶
func (p NamePattern) Parse(resourcename string) (map[string]string, error)
Parse() parses all variable segments of a pattern from a given resource name into a map[string]string, where key is the name of the variable segment and value is the value of that segment in the resource name.
Click to show internal directories.
Click to hide internal directories.