Module: ObjectStorage::CDN::Concern
- Extended by:
- ActiveSupport::Concern
- Includes:
- Gitlab::Utils::StrongMemoize
- Included in:
- JobArtifactUploader
- Defined in:
- app/uploaders/object_storage/cdn.rb
Defined Under Namespace
Classes: UrlResult
Instance Method Summary collapse
- #cdn_enabled_url(ip_address, params = {}) ⇒ Object
- #cdn_signed_url(params = {}) ⇒ Object
- #use_cdn?(request_ip) ⇒ Boolean
Instance Method Details
#cdn_enabled_url(ip_address, params = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/uploaders/object_storage/cdn.rb', line 15 def cdn_enabled_url(ip_address, params = {}) if use_cdn?(ip_address) UrlResult.new(cdn_signed_url(params), true) else UrlResult.new(url(query: params), false) end end |
#cdn_signed_url(params = {}) ⇒ Object
30 31 32 |
# File 'app/uploaders/object_storage/cdn.rb', line 30 def cdn_signed_url(params = {}) cdn_provider&.signed_url(path, params: params) end |
#use_cdn?(request_ip) ⇒ Boolean
23 24 25 26 27 28 |
# File 'app/uploaders/object_storage/cdn.rb', line 23 def use_cdn?(request_ip) return false unless .is_a?(Hash) && ['provider'] return false unless cdn_provider cdn_provider.use_cdn?(request_ip) end |