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

How far should the standard interface options go? #2

Open
analog-nico opened this issue May 2, 2016 · 3 comments
Open

How far should the standard interface options go? #2

analog-nico opened this issue May 2, 2016 · 3 comments

Comments

@analog-nico
Copy link
Member

I am wondering if the list of interface options may already be too much.

For example:

  • body taking streams may be better suited as part of streams extension that is loaded as an optional dependency
  • gzip, cookie, proxy, and tunnel are something that should be loaded as a dependency.

I am not sure if I get the purpose of the options right. Maybe the spec does not intend that all option are actually available with each implementation. Rather if it is then the options work in the specified way.

@simov
Copy link
Member

simov commented May 2, 2016

Yes you are correct, almost every option will be published in separate module. Each module should expose common interface of course. I'm actually half way through migrating all modules that are currently bundled in @request/core into separate modules. Having all options as separate modules will allow us to include them in a consistent way, and of course the main benefit will be that each option can have additional third party dependencies in it.

@analog-nico
Copy link
Member Author

That is absolutely awesome @simov !

Then I would suggest that some of the options will be marked as "minimum". If someone wants to write his own implementation of the interface he would need to support all "minimum" options/features. I think that could be these:

  • url/uri
  • qs
  • form
  • json
  • body (just for Array and String input)
  • encoding
  • headers
  • length
  • callback
  • timeout

For all other options the library would need some kind of inspection to check if that feature is supported by the implementation that it got injected. I would suggest:

request.supports('gzip') // -> true/false

This inspection doesn't seem so easy to specify to me yet. In the case of gzip some implementations may support more or less different gzip algorithms. So the .supports(...) function may need to return more detail.

But I leave it at that for now in case I digressed to much from the purpose of the spec.

@simov
Copy link
Member

simov commented May 3, 2016

Yep my initial idea was exactly that. However my idea with this spec is to only say what the interface options should be. I'm not trying to say how these options will be implement, or whether they should be implemented at all. I'm only saying that following this spec will give you certain flexibility with your implementation and you will be able to use other modules build around that spec.

For example you as implementator can create much more sophisticated HTTP client for your users, including the supports method.

Another example would be that I'm going to create a @request/legacy HTTP client that follows this spec, and includes all available @request/modules, and enables all available options by default. Just for backward compatibility.

Also I just updated the docs and added TOC at the top. Take a look at the Promises examples and #3

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

No branches or pull requests

2 participants