Nebo15 / annon.api

Configurable API gateway that acts as a reverse proxy with a plugin system.
http://docs.annon.apiary.io/
MIT License
332 stars 26 forks source link

RFC: Rework request URL (path, host, etc.) matching #252

Open AndrewDryga opened 7 years ago

AndrewDryga commented 7 years ago

Right now we are using PostgreSQL-style pattern matching with % and _, even trough it works, there are some limits and features that we want to support:

  1. We want to match paths /some_api and /some_api/123 as different APIs. Current workaroung is defining /some_api_ and /some_api/_% with different match_priority. It looks ugly and will match /some_api1, which will unexpected for most users.

  2. It would be really awesome to take parts of request and substitute them to upstream path. Eg: /blog/:id/comments -> /comments/:id.

  3. Regex matching is expensive.

AndrewDryga commented 7 years ago

First implementation proposal is to use Plug-style matching in all routes, It's even possible to leverage existing codebase for that.

AndrewDryga commented 6 years ago

Some useful code can be found here: https://github.com/inaka/cowboy-trails