-
Notifications
You must be signed in to change notification settings - Fork 88
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
Allow passing URLRequest as PathConfiguration source #127
Conversation
Is it worth exploring a configuration setting on Path Configuration to replicate this caching behavior? |
That's a good question! For the use case I describe, we need control of the public struct PathConfigurationLoaderOptions {
/// If present, the ``PathConfigurationLoader`` will initialize a new `URLSession` with
/// this configuration to make its network request
let urlSessionConfiguration: URLSessionConfiguration?
} (Naming a configuration struct for a Configuration class is hard!)
public init(sources: [Source] = [], options: PathConfigurationLoaderOptions? = nil) and the options flow down to the let session = options?.urlSessionConfiguration.map { URLSession(configuration: $0) } ?? URLSession.shared
session.dataTask(with: url) ... Was this the kind of solution you had in mind? It does set up a nice structure for further customization down the road, if there's appetite for that, but it's also a bit more complex of course. |
This structure would be a good idea to explore, but for our use case right now a minor update feels like the way to go. |
@joemasilotti I'll leave this open until tomorrow in case you have feedback on the configuration option above. |
Nope! If we keep it simple like this it looks good to me. 👍 |
This set up allows for future configuration of the loader and keeps the PathConfiguration.Source enum focused on the source of the config file rather than the specific method of obtaining the file.
098d1e0
to
4ef7797
Compare
I thought we were going with the request and not full on configuration? What sparked the last minute change? |
This non-breaking change introduces another case to the
PathConfiguration.Source
enum, a.serverRequest(URLRequest)
so that clients can customize how the configuration file is loaded from the network.This was prompted by our use in HEY – we'd like to be able to set a different cache policy on the request so that locally cached files are ignored and we always retrieve the latest possible file from the server. But I can see this being a reasonable use case for other clients too, while default behaviour is still provided by the
.server(URL)
source type.