@@ -414,7 +414,7 @@ func initializeExternalLocations(
414414 }
415415 if ! exactPathExists {
416416 externalLocExact := http.Location {
417- Path : exactPath (externalLocPath ),
417+ Path : exactPath (rule . Path ),
418418 Type : locType ,
419419 }
420420 extLocations = append (extLocations , externalLocExact )
@@ -977,19 +977,31 @@ func exactPath(path string) string {
977977 return fmt .Sprintf ("= %s" , path )
978978}
979979
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+
980988// createPath builds the location path depending on the path type.
981989func createPath (rule dataplane.PathRule ) string {
982990 switch rule .PathType {
983991 case dataplane .PathTypeExact :
984992 return exactPath (rule .Path )
993+ case dataplane .PathTypePrefix :
994+ return prefixPath (rule .Path )
995+ case dataplane .PathTypeRegularExpression :
996+ return regularExpressionPath (rule .Path )
985997 default :
986- return rule . Path
998+ return "" // should never happen because path type is validated earlier
987999 }
9881000}
9891001
9901002func createDefaultRootLocation () http.Location {
9911003 return http.Location {
992- Path : "/" ,
1004+ Path : "= /" ,
9931005 Return : & http.Return {Code : http .StatusNotFound },
9941006 }
9951007}
0 commit comments