Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

How to provide custom HttpDefaultHeaders #722

Closed
zoechi opened this issue Mar 13, 2014 · 6 comments
Closed

How to provide custom HttpDefaultHeaders #722

zoechi opened this issue Mar 13, 2014 · 6 comments

Comments

@zoechi
Copy link
Contributor

zoechi commented Mar 13, 2014

I was curious how to solve the problem described here http://stackoverflow.com/questions/21943550

In the issues Registering the same type twice in a single module should provide an error rather than silent override of the type. #48 and [WIP]Prevent overriding providers by default (fix #48) #51 you discussed that it should not be allowed to override a binding (I don't understand why you want to prevent this).
So this seems not to be a solution for the SO question.

How can custom default headers be set then?

@vicb
Copy link
Contributor

vicb commented Mar 13, 2014

IIRC what was discussed is that it should not be possible to register twice the same type for the same module:

new Module()..value(foo, ...)..value(foo, ...);

Overriding a binding is of course valid.

@vicb vicb closed this as completed Mar 13, 2014
@zoechi
Copy link
Contributor Author

zoechi commented Mar 13, 2014

Ok, I understand, that makes of course sense.
But I was not able to modify HttpDefaultHeaders like you showed on the StackOverflow answer and I was not able to get a custom MyHttpDefaultHeaders implements HttpDefaultHeaders, that I have registered in MyAppModule type(HttpDefaultHeaders, implementedBy: MyHttpDefaultHeaders) to get injected to Http.

@vicb
Copy link
Contributor

vicb commented Mar 13, 2014

How do you format Dart code on SO ?

If you send me a zip with your test setup, I'll take a look (see my email address on my GH profile)

@zoechi
Copy link
Contributor Author

zoechi commented Mar 13, 2014

I did this in some of my projects.
I will make a simple test repo and send you the zip or link probably
tomorrow.

To make a text block a code block just select the text and press the
toolbar button [ {} ]
or indent the text 4 spaces manually .

To activate syntax highlighting add

<!-- language: lang-dart -->

just before the code block with a blank line in between, not indented

or

<!-- language-all: lang-dart -->

with a blank before and after

Questions and answers have some links [ share | edit | close | flag ](below the tags [ dart ] [ angular-dart]).
You can just look at the markup using the edit link and check how others
did it (might be depend on your reputation)

@vicb
Copy link
Contributor

vicb commented Mar 13, 2014

I have a bad reputation :(

@zoechi
Copy link
Contributor Author

zoechi commented Mar 14, 2014

Why would you think that?? Ahh, just the points of SO. Nothing to worry everyone starts with 1 ;-)
Otherwise your reputation is perfect as far as I can tell!

While setting up the sample app I saw that my attempt that failed the last time seems to work now.
I had some troubles verifying it because the debbuger failed me but a print output showed that my provided defaults are returned from the injector inside an NgComponent and I just assume Http would get the same values.

Event though (I assume) I got it working I find it weird how this is built.

The code is on SO.

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

No branches or pull requests

2 participants