Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Lots of functions missing interface to request #148

Open
dan-f opened this issue May 2, 2017 · 11 comments
Open

Lots of functions missing interface to request #148

dan-f opened this issue May 2, 2017 · 11 comments
Assignees
Labels

Comments

@dan-f
Copy link
Contributor

dan-f commented May 2, 2017

I need to be able to set headers etc. in the request. Many functions in solid-client are missing this ability.

e.g. https://github.com/solid/solid-client/blob/master/src/solid/profile.js#L619-L658

@dan-f dan-f added the bug label May 2, 2017
@dmitrizagidulin
Copy link
Contributor

Those are at a higher level of abstraction than setting up request headers, though. The idea with these is that you set up the web client (including whatever custom headers) once, and the solid-client functions just use that.

@dan-f
Copy link
Contributor Author

dan-f commented May 3, 2017

It's quite possible that one would need to use different headers on each request.

@dmitrizagidulin
Copy link
Contributor

It's possible, sure. It doesn't quite seem right, from a design standpoint. If one is asking a developer to manually juggle http headers with each function call, something about that level of abstraction is not right.

@dan-f
Copy link
Contributor Author

dan-f commented May 3, 2017

The interface you export in solid-client prevents the developer from "setting up the web client (including whatever custom headers) once", since it actually injects the web client into the profile for you

@dmitrizagidulin
Copy link
Contributor

Which means you can override it centrally, once, and that propagates to the various components (like the profile-related functions).

@deiu
Copy link
Contributor

deiu commented May 3, 2017

It's possible, sure. It doesn't quite seem right, from a design standpoint. If one is asking a developer to manually juggle http headers with each function call, something about that level of abstraction is not right.

But what if you need to make requests to different servers using different authorization bearer tokens? Are you supposed to initialize the Solid client every time?

@dan-f
Copy link
Contributor Author

dan-f commented May 3, 2017

Which means you can override it centrally, once, and that propagates to the various components (like the profile-related functions).

No, you can't, not the way this is currently built. Your webclient abstraction is constructed by the index module (not by a client developer) and injected into the profile. Unless you're suggesting that developers should go create their own web client object, and mutate the profile object directly with that new webclient object, which is an unacceptable interface.

@dmitrizagidulin
Copy link
Contributor

dmitrizagidulin commented May 3, 2017

@deiu no, that would be even worse than manually having to pass in custom headers. We'd need to add a "token by intended relying party" store to the web client, so that stuff is handled automatically.

@dmitrizagidulin
Copy link
Contributor

@dan-f not at all suggesting that. They can customize the web client directly from the solid-client instance, like solid.web.whatever = ...

@dan-f
Copy link
Contributor Author

dan-f commented May 3, 2017

@dan-f not at all suggesting that. They can customize the web client directly from the solid-client instance, like solid.web.whatever = ...

No, they can't. The closures you set up on those linked functions mean that solid.web = ... will not have that effect.

The point is that I cannot set headers where I want to using solid-client. Even if I could mutate the web client object, there's no data on that object which specifies headers to be used on each request.

@dmitrizagidulin
Copy link
Contributor

I think you're mis-understanding the situation. A reference to the web client is passed into those linked functions. And that same reference is set on the solid-client instance, so modifying it there will reflect inside those functions.

there's no data on that object which specifies headers to be used on each request

True, which is a different issue. That's the bit that needs to be added, but my point in this discussion is that it needs to be added centrally, on the web client level, and not in each function.

@dmitrizagidulin dmitrizagidulin self-assigned this May 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants