apazureck / odatatools

OData Tools for vscode
24 stars 12 forks source link

Allow custom headers to be added to Proxy #11

Closed randbrown closed 7 years ago

randbrown commented 7 years ago

Trying out the Proxy generation. It seems useful, but in my case I need to pass along additional headers in the web api calls (bearer token). Is there a way to do this now? Or does the generated proxy need to be modified to allow headers to be defined? Ideally the additional headers would be allowed in the constructor AND as a public property so we can add/remove headers without re-constructing the proxy.

apazureck commented 7 years ago

Hi,

You have to change the odataproxybase.ts, if you would like to pass them in the constructor. I'll note that for the next update. We are just testing the bound odata actions generation along with our project we are currently using the generator for, but this may take a week or two. After that is more or less safe I would put out another release.

For now you can change it yourself, sorry. But it is a minor change. I already add custom headers on each request, so you could just create a headers object and iterate over it onn each request. Don't forget to save your custom generator, as the odataproxybase.ts is overwritten each time you generate a new proxy.

Maybe it would also be useful to add headers on each request, too.

If you'd like to fork and implement it, I would much appreciate that, please use the development branch for development (giflow). Or send me your code and I'll put it in here.

apazureck commented 7 years ago

Implemented with last release 0.4.0