|
|
|
@ -396,7 +396,7 @@ func (r *Route) Schemes(schemes ...string) *Route { |
|
|
|
for k, v := range schemes { |
|
|
|
for k, v := range schemes { |
|
|
|
schemes[k] = strings.ToLower(v) |
|
|
|
schemes[k] = strings.ToLower(v) |
|
|
|
} |
|
|
|
} |
|
|
|
if r.buildScheme == "" && len(schemes) > 0 { |
|
|
|
if r.getBuildScheme() == "" && len(schemes) > 0 { |
|
|
|
r.buildScheme = schemes[0] |
|
|
|
r.buildScheme = schemes[0] |
|
|
|
} |
|
|
|
} |
|
|
|
return r.addMatcher(schemeMatcher(schemes)) |
|
|
|
return r.addMatcher(schemeMatcher(schemes)) |
|
|
|
@ -488,8 +488,8 @@ func (r *Route) URL(pairs ...string) (*url.URL, error) { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
scheme = "http" |
|
|
|
scheme = "http" |
|
|
|
if r.buildScheme != "" { |
|
|
|
if s := r.getBuildScheme(); s != "" { |
|
|
|
scheme = r.buildScheme |
|
|
|
scheme = s |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if r.regexp.path != nil { |
|
|
|
if r.regexp.path != nil { |
|
|
|
@ -534,8 +534,8 @@ func (r *Route) URLHost(pairs ...string) (*url.URL, error) { |
|
|
|
Scheme: "http", |
|
|
|
Scheme: "http", |
|
|
|
Host: host, |
|
|
|
Host: host, |
|
|
|
} |
|
|
|
} |
|
|
|
if r.buildScheme != "" { |
|
|
|
if s := r.getBuildScheme(); s != "" { |
|
|
|
u.Scheme = r.buildScheme |
|
|
|
u.Scheme = s |
|
|
|
} |
|
|
|
} |
|
|
|
return u, nil |
|
|
|
return u, nil |
|
|
|
} |
|
|
|
} |
|
|
|
@ -649,11 +649,22 @@ func (r *Route) buildVars(m map[string]string) map[string]string { |
|
|
|
|
|
|
|
|
|
|
|
// parentRoute allows routes to know about parent host and path definitions.
|
|
|
|
// parentRoute allows routes to know about parent host and path definitions.
|
|
|
|
type parentRoute interface { |
|
|
|
type parentRoute interface { |
|
|
|
|
|
|
|
getBuildScheme() string |
|
|
|
getNamedRoutes() map[string]*Route |
|
|
|
getNamedRoutes() map[string]*Route |
|
|
|
getRegexpGroup() *routeRegexpGroup |
|
|
|
getRegexpGroup() *routeRegexpGroup |
|
|
|
buildVars(map[string]string) map[string]string |
|
|
|
buildVars(map[string]string) map[string]string |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Route) getBuildScheme() string { |
|
|
|
|
|
|
|
if r.buildScheme != "" { |
|
|
|
|
|
|
|
return r.buildScheme |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if r.parent != nil { |
|
|
|
|
|
|
|
return r.parent.getBuildScheme() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return "" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// getNamedRoutes returns the map where named routes are registered.
|
|
|
|
// getNamedRoutes returns the map where named routes are registered.
|
|
|
|
func (r *Route) getNamedRoutes() map[string]*Route { |
|
|
|
func (r *Route) getNamedRoutes() map[string]*Route { |
|
|
|
if r.parent == nil { |
|
|
|
if r.parent == nil { |
|
|
|
|