Documentation
¶
Overview ¶
Package matcher exposes the main interfaces and structs that can be used to test `eskip` routes.
Example ¶
m, err := New(&Options{ RoutesFile: "./testdata/routes.eskip", }) if err != nil { log.Fatal(err) return } result := m.Test(&RequestAttributes{ Method: "GET", Path: "/bar", Headers: map[string]string{ "Accept": "application/json", }, }) route := result.Route() if route != nil { fmt.Println(route.Id)
Output: bar
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matcher ¶
type Matcher interface { // Given request attributes test if a route matches Test(attributes *RequestAttributes) TestResult }
Matcher helps testing eskip routing logic
type Options ¶
type Options struct { // Path to a .eskip file defining routes RoutesFile string // CustomPredicates list of of custom Skipper predicate specs CustomPredicates []routing.PredicateSpec // CustomFilters lister of custom Skipper filter specs CustomFilters []filters.Spec // MockFilters list of custom Skipper filters to mock by name MockFilters []string // IgnoreTrailingSlash Skipper option IgnoreTrailingSlash bool // Verbose verbose debug output Verbose bool }
Options when creating a NewMatcher
type RequestAttributes ¶
RequestAttributes represents the http request attributes to test
type TestResult ¶
type TestResult interface { // Matching route if there was match nil if no match Route() *eskip.Route // The http request that was used to perform the test Request() *http.Request // Normalized request attributes after test Attributes() *RequestAttributes // Nice string representation PrettyPrint() string // Nice string representation line by line PrettyPrintLines() []string }
TestResult result of a Matcher.Test operation
Click to show internal directories.
Click to hide internal directories.