@@ -21,6 +21,8 @@ type RoutingRuleBase = {
2121 description : string
2222 /** if we should keep going even if we already have potential response */
2323 continue ?: true
24+ /** this will allow to evaluate route even if previous route was matched and didn't have continue: true */
25+ override ?: true
2426}
2527
2628type Match = {
@@ -142,12 +144,20 @@ async function match(
142144 let currentRequest = request
143145 let maybeResponse : MaybeResponse = initialResponse
144146
147+ let onlyOverrides = false
148+
145149 return tracer . withActiveSpan ( spanName , async ( span ) => {
146150 for ( const rule of routingRules ) {
147151 const currentURL = new URL ( currentRequest . url )
148152 const { pathname } = currentURL
149153
150154 const desc = rule . description ?? JSON . stringify ( rule )
155+
156+ if ( onlyOverrides && ! rule . override ) {
157+ log ( 'Skipping rule because there is a match and this is not override:' , desc , pathname )
158+ continue
159+ }
160+
151161 // eslint-disable-next-line no-loop-func
152162 const result = await tracer . withActiveSpan ( desc , async ( span ) => {
153163 log ( 'Evaluating rule:' , desc , pathname )
@@ -472,18 +482,19 @@ async function match(
472482 }
473483
474484 if ( matched && ! shouldContinueOnMatch ) {
485+ onlyOverrides = true
475486 // once hit a match short circuit, unless we should continue
476- return { maybeResponse, currentRequest }
487+ // return { maybeResponse, currentRequest }
477488 }
478489
479490 if ( ! matched ) {
480491 span . setStatus ( { code : SpanStatusCode . ERROR , message : 'Miss' } )
481492 }
482493 } )
483494
484- if ( result ) {
485- return result
486- }
495+ // if (result) {
496+ // return result
497+ // }
487498 }
488499 return { maybeResponse, currentRequest }
489500 } )
0 commit comments