Allow http headers to be configured for bike rental updaters#3533
Conversation
|
#2544 adds |
t2gran
left a comment
There was a problem hiding this comment.
I guess the discussion here is if we should add the ability to configure all bike updaters with a map of headers. This PR make all the necessary steps - but not the tiny last one, so if we allow for this code change with extra the complexity, then it also seems fare to add the ability to the other updaters as well.
|
I vote for adding headers to bike-updaters, that would pave the way for adding it to other updaters later, like the GTFS-RT updater in #2544. If we do so, the documentation also needs updating. |
| network(), | ||
| routeAsCar(), | ||
| allowKeepingBicycleRentalsAtDestination(), | ||
| c.asMap("headers", NodeAdapter::asText) |
There was a problem hiding this comment.
All the other parameters have nice little methods here, it would be nice to follow the same pattern - giving the parameter a name. I think the parameter should be named httpHeader since the context is a BikeRentalDataSource.
| return apiKey; | ||
| } | ||
|
|
||
| public Map<String, String> getHttpHeaders() { |
There was a problem hiding this comment.
I think this should be @Nonnull so we do not have to check for null later. Add @Nonnull to the constructor parameter as well.
| super( | ||
| config, | ||
| "stations", | ||
| config.getApiKey() != null ? Map.of("Client-Identifier", config.getApiKey()) : Map.of() |
There was a problem hiding this comment.
Is it now possible to remove the Entur specific ApiKey? An replace it just by adding config in our deployment ?
There was a problem hiding this comment.
That would be possible, but we are not using this updater anymore, and I think it might be removed by @leonardehrenfried soon?
flaktack
left a comment
There was a problem hiding this comment.
One minor thing: could you add the headers to the configureUrls / GbfsAutoDiscoveryDataSource so that is is also used there?
Summary
This allows arbitrary http headers to be added to bike rental updaters. At Entur this is useful, because we read headers in other components to know where the traffic is coming from.
I have changed the bike rental updater classes and HttpUtils to accept a map of headers. The BikeRentalServiceDirectoryFetcher sandbox feature is also changed to make headers configureable in router-config. If needed, this could also be configurable for individual updaters.
Issue
No issue
Unit tests
Tested manually
Documentation
Documented with javadoc
Changelog
Added to changelog