Skip to content

Commit f5520f8

Browse files
committed
Adds support to specify upload endpoint
Fixes piotrmurach#259
1 parent 0859a68 commit f5520f8

File tree

6 files changed

+13
-4
lines changed

6 files changed

+13
-4
lines changed

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,6 @@ DEPENDENCIES
118118
webmock (~> 1.17.3)
119119
yard (~> 0.8.7)
120120
yardstick (~> 0.9.9)
121+
122+
BUNDLED WITH
123+
1.10.3

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ Alternatively, you can configure the settings by passing a block to an instance
293293
Github.new do |c|
294294
c.endpoint = 'https://github.company.com/api/v3'
295295
c.site = 'https://github.company.com'
296+
c.upload_endpoint = 'https://github.company.com'
296297
end
297298
```
298299

@@ -609,9 +610,9 @@ class GithubController < ApplicationController
609610
access_token = github.get_token authorization_code
610611
access_token.token # => returns token value
611612
end
612-
613+
613614
private
614-
615+
615616
def github
616617
@github ||= Github.new client_id: '...', client_secret: '...'
617618
end

lib/github_api/client/repos/releases/assets.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def upload(*args)
7070
file = Faraday::UploadIO.new(arguments.filepath, type)
7171
options = {
7272
headers: { content_type: type },
73-
endpoint: 'https://uploads.github.com',
73+
endpoint: upload_endpoint,
7474
query: {'name' => params['name']}
7575
}
7676
params['data'] = file.read

lib/github_api/configuration.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class Configuration < API::Config
3030
# The web endpoint used to connect to GitHub if none is set
3131
property :site, default: 'https://github.com'.freeze
3232

33+
# The web endpoint used to upload release assets to GitHub if none is set
34+
property :upload_endpoint, default: 'https://uploads.github.com'.freeze
35+
3336
# The default SSL configuration
3437
property :ssl, default: {
3538
:ca_file => File.expand_path('../ssl_certs/cacerts.pem', __FILE__)

spec/github/client/repos/assets/upload_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
let(:id) { 1 }
99
let(:filepath) { 'batman.js' }
1010
let(:file) { double(:file, read: nil, close: nil) }
11-
let(:endpoint) { 'https://uploads.github.com' }
11+
let(:endpoint) { Github.upload_endpoint }
1212
let(:inputs) { {name: 'batman.jpg', content_type: 'application/javascript'} }
1313
let(:path) { "/repos/#{owner}/#{repo}/releases/#{id}/assets" }
1414

spec/github/configuration_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
its(:site) { should == 'https://github.com' }
1616

17+
its(:upload_endpoint) { should == 'https://uploads.github.com' }
18+
1719
its(:user_agent) { should =~ /Github API Ruby Gem/ }
1820

1921
its(:oauth_token) { should be_nil }

0 commit comments

Comments
 (0)