Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Support for email address ( resource with .) in resource uri #20

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rohitjoshi
Copy link

  1. I have added support for dot (.) in resource uri e.g /emails/:email/devices and request uri is /emails/[email protected]/devices
  2. Updated readme to replace ngx.var.request_uri with ngx.var.uri . This will support uri without any subresources.

@mikz
Copy link
Contributor

mikz commented Apr 6, 2016

@rohitjoshi I don't think replacing all strings with constants should be done in the same PR as adding a support for .. Also, it fails the build because some are unused https://travis-ci.org/APItools/router.lua/jobs/121157963

Could you commit just the support for . so it is easier to review?

If you feel moving those constants to string improves something (like performance), i'd like see proof. I don't think it adds readability. On the contrary.

@@ -41,12 +41,6 @@ describe("Router", function()
assert.same(dummy.params, {id="2"})
end)

it("supports an extension on a param", function()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we definitely want to support those

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding support for dot (.) conflict with your requirement of supporting extension for the resource.

e.g you have a test case /resource/1.json where you expect resource value to be 1
By adding support for ., it will return 1.json
e.g /users/[email protected] should return [email protected]
So unless we remove support for extension, dot support will not work.

Regarding defining constants, I had ran this test long ago and most of the time JIT does optimize but with millions of requests, I was able to see the difference. I do agree performance gain may not be significant compared to readability.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a test testing support for the .. I just see removing support for partial matching.

The tests are testing that /:id.json extracts 1. I don't see how that could conflict with /:email matching the whole string. It might be not easy because of how it is implemented, but that does not mean it is not possible.

I can't merge such breaking functionality, sorry. I'd be fine merging it, if it would not break current tests and remove existing functionality.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will submit another PR with

  1. email support
  2. remove const strings

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants