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

Remove Request pass through methods #1396

Open
stevehipwell opened this issue Jul 4, 2017 · 8 comments
Open

Remove Request pass through methods #1396

stevehipwell opened this issue Jul 4, 2017 · 8 comments

Comments

@stevehipwell
Copy link

@stevehipwell stevehipwell commented Jul 4, 2017

Feature Request

Use Case

Remove the pass through methods on Request to make the API more consistent as well as fix a bug where res.query() is overwritten by res.query when using the queryParser plugin.

Now is the time to do this as part of the v5 release.

Example API

Remove the following API endpoints.

res.contentLength()
res.contentType()
res.href()
res.id()
res.path()
res.query()
res.version()

Are you willing and able to implement this?

Yes

@retrohacker
Copy link
Member

@retrohacker retrohacker commented Jul 4, 2017

It looks like these are aliased, is there a compelling reason for removing them all as opposed to fixing the plugin?

I'm 👍 on consistency, and it seems like all of these are actually synchronous so we could just create a getter on the property (i.e. length = res.contentLength). While making the setter no-op and creating a getter may make this API a bit more clean, I'm worried about migration costs for making this change. It seems like this will break user-land in a massive way.

@stevehipwell
Copy link
Author

@stevehipwell stevehipwell commented Jul 5, 2017

@retrohacker - I would suggest that the query parser behaviour of setting res.query to a hash object is the expected behaviour rather than the aliased behaviour of duplicating res.getQuery().

For me aliases are a fine for keeping backward compatibility for semvar minor release but should be removed when doing a semvar major release. The Restify v5 release contains a number of API changes so I don't see the problem in doing a bit of code maintenance.

@dai1054067910
Copy link

@dai1054067910 dai1054067910 commented Jul 18, 2017

Met the same question, I am using node6.9.4, express 4.3.0 and restify 5.0.0, restify will make request.query to be a function, so that express can't parse the query string any more, because it's not null(express.middleware.query.js 39). And it broke down my project. Restify 4.3.0 works fine.
BTW, actually I don't need to use restify, but I need bpmn, and bpmn will require restify, so......,

@retrohacker
Copy link
Member

@retrohacker retrohacker commented Nov 1, 2017

Marking this as ready to implement, as it would be nice to have compatibility with express. @yunong and @DonutEspresso, chime in if you disagree.

@DonutEspresso
Copy link
Member

@DonutEspresso DonutEspresso commented Nov 15, 2017

I suspect many of the aliases are from before they existed in node core. Agree - it makes sense to use the now native methods where possible.

@hekike
Copy link
Member

@hekike hekike commented Apr 10, 2018

Related: #1422

@hekike
Copy link
Member

@hekike hekike commented Apr 10, 2018

Related: #1529

@logeekal
Copy link

@logeekal logeekal commented Mar 22, 2019

Hello,

I am starting to work on this and i understand the problem. I will explain what i understand of the problem and you can correct me if i am wrong.

  1. Methods such as req.path() are aliased to getPath() function in request.

  2. I could not find the same alias or function in response module and all the above examples are given for response which is strange. Please let me know if i am missing something.

  3. We need to get to native like functionality so that getPath() is the default behaviour rather than Path()

  4. Does this mean that we remove req.Path() completely? Can we have path as a property with a value of getPath()?

  5. Now after this change req.Path() will stop working, wouldn't this break the system already using .Path() function?

  6. I found 6 properties like that which have corresponding get property in request module and NONE in response module.

contentLength
contentType
href
path
query
version

Please confirm my thoughts. I apologise in advance if I sound ignorant at some places as this is my first stab in open source world and i am not a Rockstar in javascript as well.

Thank You
Logeekal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.