-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hey there! Thank you for this awesome library.
I'm interested in using it in nginx as a router, but for what I'm looking to do, I don't want to invoke a route handler when a route is matched. All I want is to match a request to a route, and lookup that route's metadata.
An example in pseudocode:
local r3route = require "resty.r3"
local r3 = r3route.new({
{
path = [[/foo/{:\w+}/{:\w+}"]],
method = {"GET"},
metadata = { server: foo, datacenter: us-east }
},
{
path = [[/bar/{:\w+}/{:\w+}]],
host = "*.bar.com",
metadata = { server: bar, datacenter: us-east }
},
{
path = [[/alice/{:\w+}/{:\w+}]],
metadata = { server: alice, datacenter: us-west }
},
})
-- match_route is imaginary name, similar API to r3:dispatch
local metadata = r3:match_route("GET", "/alice/one/two")
metadata.server => alice
metadata.datacenter => us-westI think this is very similar to existing API, with one difference in handler vs. metadata.
I'd be happy to contribute a patch once other contributors are onboard 👍
cc @membphis
membphis
Metadata
Metadata
Assignees
Labels
No labels