-
Notifications
You must be signed in to change notification settings - Fork 1.3k
add support for configurable API base URL #6709
Conversation
@incanus, thanks for your PR! By analyzing the history of the files in this pull request, we identified @1ec5, @frederoni and @boundsj to be potential reviewers. |
Also, I thought it best to add a new singleton class |
One item up for debate here is if To fit the current setup of returning |
Yes, that’s what I meant. An Info.plist-based implementation is ideal because the developer has an easy way to set it before MGLOfflineStorage is initialized – in the Info.plist – and because changing the base URL midstream results in undefined behavior.
MGLMapView uses MGLOfflineStorage for online functionality too. “Offline” in this context means fetching and caching, that’s all. I wonder if it’s really necessary to expose a formal API around this setting. I always imagined this setting to be more similar to the telemetry base URL Info.plist entry we had originally (before turning it into a user default): just a simple dictionary read in MGLOfflineStorage right when we initialize the file source, and no API additions whatsoever. The only benefit to a formal API would be that people can set the base URL in their application delegate instead of in the Info.plist, but I still think that’s a risky proposition. As it’s currently designed, the base URL setting is an advanced setting for a very specific use case, not something we would even mention in a guide. |
Ok, well this works out of the
Right, but that's non-obvious as well 😄 I think I'll just remove the public methods from |
/** | ||
Returns any custom API base URL in use by instances of MGLMapView and MGLOfflineStorage in the current application. | ||
*/ | ||
+ (nullable NSURL *)apiBaseURL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without a programmatic setter, there’s no point to having a getter, because the developer can just as easily call [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAPIBaseURL"]
themselves.
How about 85206fd then, which just takes the class private now? Note that I've named the (only) header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine other than the file name. (We don’t explicitly say “Private” for private-only classes.) This is still more than we actually need for the feature, but I suppose an extra private class couldn’t hurt. MGLNetworkConfiguration could be a nice place to hang reachability stuff off of in the future.
@@ -2,6 +2,7 @@ | |||
|
|||
#import "MGLAccountManager_Private.h" | |||
#import "MGLGeometry_Private.h" | |||
#import "MGLNetworkConfiguration_Private.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there’s no public version of this header, there’s no need for _Private
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thoughts exactly. |
Qt builds are failing reliably with the following error, which is certainly unrelated to these changes:
|
Filed #6712 about the Qt5 build bot failure. |
I think this fixes #6346. It's fairly identical to how access tokens work in the SDK.
The
DefaultFileSource::setAPIBaseURL()
that is called under the hood is synchronous. I think we can expect that if someone changes the API base URL midstream during a download operation, unexpected things will happen. This is the same with the access token. Is that what you meant @1ec5? Am I missing something as to why this can't be this simple?Builds on @tobrun's work in #6309.
Todo: