-
Notifications
You must be signed in to change notification settings - Fork 216
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
Create an Http service extension #14
Comments
How would I go about extending this? but the constructor never get the What I did:
What I'm trying to do: ... Further down the line I'll need to hook on every 401 answer so I know when the is no longer valid; But Ill cross that bridge when I get there :) |
Seems like an injection issue, is your export function createHttpService(backend: ConnectionBackend,
defaultOptions: RequestOptions,
httpCacheService: HttpCacheService,
authService: AuthService) {
return new HttpService(backend, defaultOptions, httpCacheService, authService);
} and your constructor(backend: ConnectionBackend,
private defaultOptions: RequestOptions,
private httpCacheService: HttpCacheService,
private authService: AuthService) {
super(backend, defaultOptions);
} If it works for As for catching 401 error, you can just hook to the |
Yep, That's exactly how I set up - and what I thought ("if it works for httpCache it should work for auth") I ended up making a layer between the Http and the app, httpClient, which will then call the Http. It's ugly, but I ain't have that much time; Will revisit this approach later and submit a propper issue if stuff goes haywire :) ps: My approach would also induce in a circular dependency, because HttpService required |
Ah, that's the issue here! Since there's no way to properly resolve such dependencies, one of the required service ends up You should properly separate the 3 concerns here: getting authentified, storing/getting credentials and providing an customized http service. That should be 3 different services, and the service for storing/getting the credentials will act as the middleman here to avoid having a circular dependency. Good luck ;) |
Provide support for server configuration depending of the environment, default headers and user-configurable cache policy.
Should go in
core
module.The text was updated successfully, but these errors were encountered: