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

GeoTIFFSource: Specifying a custom client #15677

Open
BeGj opened this issue Mar 27, 2024 · 2 comments
Open

GeoTIFFSource: Specifying a custom client #15677

BeGj opened this issue Mar 27, 2024 · 2 comments

Comments

@BeGj
Copy link

BeGj commented Mar 27, 2024

Background:
GeoTIFFSource does not accept any custom client despite geotiff.js supporting this behaviour using the method fromCustomClient (instead of fromUrl).

Proposal:
I propose that when constructing the GeoTIFFSource we allow the developer to specify a custom client.

Example use case:
In Angular it makes it possible to create a client based on Angulars' HttpClient which makes it possible to automatically add a JWT token to the header of each request using the HttpClients HttpInterceptors. This is very usefull when protecting COGs behind a protected reverse-proxy. Instead of manually updating the sources sourceOptions on every token refresh.

Sources:

  1. fromCustomClient on https://geotiffjs.github.io/geotiff.js/module-geotiff.html
  2. The pull request that enabled it Make it possible to build a RemoteSource with a user-provided client geotiffjs/geotiff.js#370

I would love any feedback on this propoasl, and I'm willing to contribute the code to make it happend. (It's just a few lines of code as I see it. no need to code any clients. Just add the possibility to overwrite with your own).

@ahocevar
Copy link
Member

I don't think we'd want to expose GeoTIFF's BaseClient and BaseResponse APIs. But we could accept a function (headers: HeadersInit, abortSignal: AbortSignal): Promise<Response> as url option.

@BeGj
Copy link
Author

BeGj commented Mar 27, 2024

I don't think we'd want to expose GeoTIFF's BaseClient and BaseResponse APIs. But we could accept a function (headers: HeadersInit, abortSignal: AbortSignal): Promise<Response> as url option.

Thank you, that is a good point which I agree on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants