Skip to content

Instantly share code, notes, and snippets.

@serhatsezer
Created November 26, 2018 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serhatsezer/7141490a8377f42c663e34a186b42e4a to your computer and use it in GitHub Desktop.
Save serhatsezer/7141490a8377f42c663e34a186b42e4a to your computer and use it in GitHub Desktop.
// MoyaCacheablePlugin.swift
final class MoyaCacheablePlugin: PluginType {
func prepare(_ request: URLRequest, target: TargetType) -> URLRequest {
if let moyaCachableProtocol = target as? MoyaCacheable {
var cachableRequest = request
cachableRequest.cachePolicy = moyaCachableProtocol.cachePolicy
return cachableRequest
}
return request
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment