@@ -204,8 +204,8 @@ func (r *Router) describe() (*gwclient.Result, error) {
204204
205205 res := gwclient .NewResult ()
206206 res .Metadata = map [string ][]byte {
207- "result.txt" : buf .Bytes (),
208- "version" : []byte (subrequests .SubrequestsDescribeDefinition .Version ),
207+ resultTextMetaKey : buf .Bytes (),
208+ "version" : []byte (subrequests .SubrequestsDescribeDefinition .Version ),
209209 }
210210 return res , nil
211211}
@@ -273,9 +273,9 @@ func queryForwardedTargets(ctx context.Context, client gwclient.Client, prefix s
273273 return nil , err
274274 }
275275
276- dt , ok := res .Metadata ["result.json" ]
276+ dt , ok := res .Metadata [resultJSONMetaKey ]
277277 if ! ok {
278- return nil , errors .New ("forwarded frontend did not return result.json" )
278+ return nil , errors .New ("forwarded frontend did not return " + resultJSONMetaKey )
279279 }
280280
281281 var remote bktargets.List
@@ -300,13 +300,13 @@ func dalecTargetListToResult(ls TargetList) (*gwclient.Result, error) {
300300 if err != nil {
301301 return nil , errors .Wrap (err , "error marshalling target list to json" )
302302 }
303- res .AddMeta ("result.json" , dtJSON )
303+ res .AddMeta (resultJSONMetaKey , dtJSON )
304304
305305 buf := bytes .NewBuffer (nil )
306306 if err := printTargets (ls , buf ); err != nil {
307307 return nil , err
308308 }
309- res .AddMeta ("result.txt" , buf .Bytes ())
309+ res .AddMeta (resultTextMetaKey , buf .Bytes ())
310310
311311 res .AddMeta ("version" , []byte (bktargets .SubrequestsTargetsDefinition .Version ))
312312 return res , nil
@@ -336,20 +336,17 @@ func printTargets(ls TargetList, w io.Writer) error {
336336}
337337
338338// lookupTarget finds the route matching the given target string.
339- // It tries exact match first, then longest prefix match.
340339// An empty target is always an error — callers must specify a target key.
340+ // Otherwise it tries exact match first, then longest prefix match.
341341func (r * Router ) lookupTarget (ctx context.Context , target string ) (matchedPath string , _ * Route , _ error ) {
342- // 1. Exact match
343- if route , ok := r .routes [target ]; ok {
344- return target , & route , nil
345- }
346-
347- // 2. Empty target — no global default; prompt the user.
348342 if target == "" {
349343 return "" , nil , handlerNotFound (target , maps .Keys (r .routes ))
350344 }
351345
352- // 3. Longest prefix match
346+ if route , ok := r .routes [target ]; ok {
347+ return target , & route , nil
348+ }
349+
353350 var candidates []string
354351 for k := range r .routes {
355352 if strings .HasPrefix (target , k + "/" ) {
0 commit comments