-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Kong server info endpoints (#14)
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Kong | ||
class Server | ||
def self.version | ||
self.info['version'] rescue nil | ||
end | ||
|
||
def self.info | ||
Client.instance.get('/') | ||
end | ||
|
||
def self.status | ||
Client.instance.get('/status') | ||
end | ||
|
||
def self.cluster | ||
Client.instance.get('/cluster') | ||
end | ||
|
||
def self.remove_node(name) | ||
Client.instance.delete("/cluster/nodes/#{name}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require_relative "../spec_helper" | ||
|
||
describe Kong::Server do | ||
describe '.info' do | ||
it 'makes GET / request' do | ||
expect(Kong::Client.instance).to receive(:get).with('/') | ||
described_class.info | ||
end | ||
end | ||
|
||
describe '.version' do | ||
it 'returns version information' do | ||
allow(Kong::Client.instance).to receive(:get).with('/') | ||
.and_return({ 'version' => '0.10.0' }) | ||
expect(described_class.version).to eq('0.10.0') | ||
end | ||
end | ||
|
||
describe '.status' do | ||
it 'makes GET /status request' do | ||
expect(Kong::Client.instance).to receive(:get).with('/status') | ||
described_class.status | ||
end | ||
end | ||
|
||
describe '.cluster' do | ||
it 'makes GET /cluster request' do | ||
expect(Kong::Client.instance).to receive(:get).with('/cluster') | ||
described_class.cluster | ||
end | ||
end | ||
|
||
describe '.remove_node' do | ||
it 'makes DELETE /cluster/nodes/:name request' do | ||
expect(Kong::Client.instance).to receive(:delete).with('/cluster/nodes/:name') | ||
described_class.remove_node(':name') | ||
end | ||
end | ||
end |