Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support provide a matched table to store matched conditions #17

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

vm-001
Copy link
Owner

@vm-001 vm-001 commented Jan 4, 2024

local Router = require "radix-router"
local router = Router.new({
  {
    paths = { "/static" },
    methods = { "GET" },
    hosts = { "example.com" },
    handler = "1",
  },
  {
    paths = { "/a/{var}", "/b/{var}" },
    methods = { "POST", "PUT" },
    hosts = { "*.example.com" },
    handler = "2",
  },
})


local matched = {}
router:match("/b/var", { method = "PUT", host = "www.example.com" }, nil, matched)
print(matched.path) -- "/b/{var}"
print(matched.host) --  "*.example.com"
print(matched.method) -- "PUT"

@vm-001 vm-001 merged commit ee36e29 into main Jan 4, 2024
6 checks passed
@vm-001 vm-001 deleted the feat/matched branch January 6, 2024 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant