@@ -414,7 +414,7 @@ func initializeExternalLocations(
414
414
}
415
415
if ! exactPathExists {
416
416
externalLocExact := http.Location {
417
- Path : exactPath (externalLocPath ),
417
+ Path : exactPath (rule . Path ),
418
418
Type : locType ,
419
419
}
420
420
extLocations = append (extLocations , externalLocExact )
@@ -977,19 +977,31 @@ func exactPath(path string) string {
977
977
return fmt .Sprintf ("= %s" , path )
978
978
}
979
979
980
+ func prefixPath (path string ) string {
981
+ return fmt .Sprintf ("^~ %s" , path )
982
+ }
983
+
984
+ func regularExpressionPath (path string ) string {
985
+ return fmt .Sprintf ("~ %s" , path )
986
+ }
987
+
980
988
// createPath builds the location path depending on the path type.
981
989
func createPath (rule dataplane.PathRule ) string {
982
990
switch rule .PathType {
983
991
case dataplane .PathTypeExact :
984
992
return exactPath (rule .Path )
993
+ case dataplane .PathTypePrefix :
994
+ return prefixPath (rule .Path )
995
+ case dataplane .PathTypeRegularExpression :
996
+ return regularExpressionPath (rule .Path )
985
997
default :
986
- return rule . Path
998
+ return "" // should never happen because path type is validated earlier
987
999
}
988
1000
}
989
1001
990
1002
func createDefaultRootLocation () http.Location {
991
1003
return http.Location {
992
- Path : "/" ,
1004
+ Path : "= /" ,
993
1005
Return : & http.Return {Code : http .StatusNotFound },
994
1006
}
995
1007
}
0 commit comments