NREL / api-umbrella

Open source API management platform
MIT License
2.03k stars 325 forks source link

Flexible frontend prefix matching without using 'matching order' field? #342

Open brylie opened 7 years ago

brylie commented 7 years ago

We allow end-users, of the Apinf platform, to add API Umbrella API backends, including defining a custom frontend prefix. This has led to some problems, such as the following frontend prefixes resolving to the wrong API Backend:

Intended:

We are noticing that API Umbrella uses a global matching order field to mitigate this issue. However, in our current UI, a global 'matching order' might not make sense to a user who has just added one or more APIs, but who may not be responsible for the remaining APIs.

What are some ideas as to how we might allow end-users to add APIs, so that calls resolve in an intuitive/expected way?

GUI commented 7 years ago

Hm, I thought we had some existing discussion threads around some alternatives to our current "matching order" approach, but I can't find them, so maybe those didn't happen here (the closest is https://github.com/18F/api.data.gov/issues/186, which discusses the need to warn admins about conflicts, but not about different approaches).

In any case, one potential alternative I've discussed in the past is to always give precedence to more specific prefixes based on length. I might be over-simplfying this now, but I think the basic approach would be to sort all the prefixes by total string length (in descending order), and then use that as the matching order. That should ensure that more specific URL prefixes are always matched ahead of more general prefixes (since /music/alternative/ is longer in length than /music, the longer one would always be matched first).

There might be edge-cases I'm not thinking about right now, but I do think something like this would be a lot more intuitive, and it would eliminate the need for explicit matching orders and conflict detection.

A few more things to consider if we make this change:

brylie commented 7 years ago

cc: @bajiat @marla-singer

brylie commented 7 years ago

@GUI, we realize that this change would ideally be made at the Proxy layer, hence this issue. How can we support this work?