@@ -396,7 +396,7 @@ func (r *Route) Schemes(schemes ...string) *Route {
396
396
for k , v := range schemes {
397
397
schemes [k ] = strings .ToLower (v )
398
398
}
399
- if r .buildScheme == "" && len (schemes ) > 0 {
399
+ if r .getBuildScheme () == "" && len (schemes ) > 0 {
400
400
r .buildScheme = schemes [0 ]
401
401
}
402
402
return r .addMatcher (schemeMatcher (schemes ))
@@ -488,8 +488,8 @@ func (r *Route) URL(pairs ...string) (*url.URL, error) {
488
488
return nil , err
489
489
}
490
490
scheme = "http"
491
- if r . buildScheme != "" {
492
- scheme = r . buildScheme
491
+ if s := r . getBuildScheme (); s != "" {
492
+ scheme = s
493
493
}
494
494
}
495
495
if r .regexp .path != nil {
@@ -534,8 +534,8 @@ func (r *Route) URLHost(pairs ...string) (*url.URL, error) {
534
534
Scheme : "http" ,
535
535
Host : host ,
536
536
}
537
- if r . buildScheme != "" {
538
- u .Scheme = r . buildScheme
537
+ if s := r . getBuildScheme (); s != "" {
538
+ u .Scheme = s
539
539
}
540
540
return u , nil
541
541
}
@@ -649,11 +649,22 @@ func (r *Route) buildVars(m map[string]string) map[string]string {
649
649
650
650
// parentRoute allows routes to know about parent host and path definitions.
651
651
type parentRoute interface {
652
+ getBuildScheme () string
652
653
getNamedRoutes () map [string ]* Route
653
654
getRegexpGroup () * routeRegexpGroup
654
655
buildVars (map [string ]string ) map [string ]string
655
656
}
656
657
658
+ func (r * Route ) getBuildScheme () string {
659
+ if r .buildScheme != "" {
660
+ return r .buildScheme
661
+ }
662
+ if r .parent != nil {
663
+ return r .parent .getBuildScheme ()
664
+ }
665
+ return ""
666
+ }
667
+
657
668
// getNamedRoutes returns the map where named routes are registered.
658
669
func (r * Route ) getNamedRoutes () map [string ]* Route {
659
670
if r .parent == nil {
0 commit comments