Skip to content

Commit

Permalink
Prefix all API routes with /api
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl-Aksel Puulmann committed Feb 3, 2017
1 parent bdd19e6 commit f7912de
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
22 changes: 11 additions & 11 deletions lib/admin/admin_server.rb
Expand Up @@ -64,7 +64,7 @@ def can_connect_to_pd(pagerduty=nil)
File.new('public/index.html').readlines
end

get '/pagerduty' do
get '/api/pagerduty' do
protected!
content_type :json
({
Expand All @@ -73,7 +73,7 @@ def can_connect_to_pd(pagerduty=nil)
}).to_json
end

post '/pagerduty' do
post '/api/pagerduty' do
protected!
content_type :json
settings = json_args request
Expand Down Expand Up @@ -104,14 +104,14 @@ def can_connect_to_pd(pagerduty=nil)
hipchat: {}
}

get '/bot' do
get '/api/bot' do
protected!
content_type :json

store.get_or_create('bot', bot_defaults).to_json
end

post '/bot' do
post '/api/bot' do
protected!
content_type :json

Expand All @@ -123,7 +123,7 @@ def can_connect_to_pd(pagerduty=nil)
}.to_json
end

get '/plugins' do
get '/api/plugins' do
protected!
content_type :json

Expand All @@ -147,7 +147,7 @@ def can_connect_to_pd(pagerduty=nil)
}.to_json
end

post '/plugins' do
post '/api/plugins' do
protected!
content_type :json
plugins = json_args(request).fetch(:plugins)
Expand All @@ -164,7 +164,7 @@ def can_connect_to_pd(pagerduty=nil)
end

# Alias api methods
post '/normalize_strings' do
post '/api/normalize_strings' do
protected!
content_type :json

Expand All @@ -174,7 +174,7 @@ def can_connect_to_pd(pagerduty=nil)
}.to_json
end

get '/users' do
get '/api/users' do
protected!
content_type :json
store.update_collection! 'users'
Expand All @@ -187,7 +187,7 @@ def can_connect_to_pd(pagerduty=nil)
}.to_json
end

post '/users' do
post '/api/users' do
protected!
content_type :json
added_users = json_args(request).fetch(:users)
Expand All @@ -202,7 +202,7 @@ def can_connect_to_pd(pagerduty=nil)
}.to_json
end

get '/schedules' do
get '/api/schedules' do
protected!
content_type :json

Expand All @@ -215,7 +215,7 @@ def can_connect_to_pd(pagerduty=nil)
}.to_json
end

post '/schedules' do
post '/api/schedules' do
protected!
content_type :json
added_schedules = json_args(request).fetch(:schedules)
Expand Down
8 changes: 4 additions & 4 deletions public/js/app.js
Expand Up @@ -23,28 +23,28 @@
templateUrl: 'views/bot.html',
controller: 'BotSetupCtrl',
resolve: {
bot_info: get_promise('/bot')
bot_info: get_promise('/api/bot')
}
})
.when('/plugin-setup', {
templateUrl: 'views/plugins.html',
controller: 'PluginSetupCtrl',
resolve: {
plugin_info: get_promise('/plugins')
plugin_info: get_promise('/api/plugins')
}
})
.when('/user-aliases', {
templateUrl: 'views/users.html',
controller: 'UserAliasCtrl',
resolve: {
users: get_promise('/users')
users: get_promise('/api/users')
}
})
.when('/schedule-aliases', {
templateUrl: 'views/schedules.html',
controller: 'ScheduleAliasCtrl',
resolve: {
schedules: get_promise('/schedules')
schedules: get_promise('/api/schedules')
}
})
.when('/deploy', {
Expand Down
4 changes: 2 additions & 2 deletions public/js/controllers/bot-setup.js
Expand Up @@ -23,7 +23,7 @@ angular.module('pagerbot-admin')
$scope.status = 'saving';
$scope.validateSlackConnection(bot_info);

$http.post('/bot', bot_info)
$http.post('/api/bot', bot_info)
.success(function(response) {
$rootScope.bot = response.saved;
});
Expand Down Expand Up @@ -61,7 +61,7 @@ angular.module('pagerbot-admin')
return;
}
$scope.auth.can_connect = 'validating';
$http.get("https://slack.com/api/auth.test?token="+token)
$http.get('https://slack.com/api/auth.test?token='+token)
.success(function(response) {
if (response.ok) {
$scope.auth.can_connect = 'yes';
Expand Down
2 changes: 1 addition & 1 deletion public/js/controllers/main.js
Expand Up @@ -6,7 +6,7 @@ angular.module('pagerbot-admin')
return r == $location.path();
};

$http.get('/bot').success(function(response) {
$http.get('/api/bot').success(function(response) {
console.log("Bot info:", response);
$rootScope.bot = response;
});
Expand Down
4 changes: 2 additions & 2 deletions public/js/controllers/pagerduty.js
Expand Up @@ -14,11 +14,11 @@ angular.module('pagerbot-admin')
$scope.status = 'saving';
$rootScope.can_connect = false;

$http.post('/pagerduty', pagerduty)
$http.post('/api/pagerduty', pagerduty)
.success(function(response) {
$rootScope.pagerduty = response.saved;
$rootScope.can_connect = response.can_connect;
$scope.status = 'saved';
});
};
});
});
2 changes: 1 addition & 1 deletion public/js/controllers/plugin-setup.js
Expand Up @@ -15,7 +15,7 @@ angular.module('pagerbot-admin')
console.log("Saving plugin settings:", plugin_info);
$scope.status = 'saving';

$http.post('/plugins', plugin_info)
$http.post('/api/plugins', plugin_info)
.success(function(response) {
$scope.plugins = response.saved;
});
Expand Down
10 changes: 5 additions & 5 deletions public/js/services/alias_manager.js
Expand Up @@ -2,7 +2,7 @@

angular.module('pagerbot-admin')
.factory('pagerduty_promise', function($http) {
return $http.get('/pagerduty');
return $http.get('/api/pagerduty');
})
.factory('alias_manager', function($http, $delayed_watch, $filter, ngTableParams) {
var setupTable = function(collection) {
Expand Down Expand Up @@ -56,7 +56,7 @@ angular.module('pagerbot-admin')
service.save = function(collection) {
console.log("Saving", collection_name, collection);

$http.post('/'+collection_name, collection)
$http.post('/api/'+collection_name, collection)
.success(function(response) {
console.debug("Save result:", response.saved);
$scope[collection_name] = response.saved;
Expand All @@ -73,7 +73,7 @@ angular.module('pagerbot-admin')
member.aliases.push({ name: name, automatic: false });

// slightly racy
$http.post('/normalize_strings', {strings: [name]})
$http.post('/api/normalize_strings', {strings: [name]})
.success(function(strings) {
member.aliases[index].name = strings.strings[0];
});
Expand Down Expand Up @@ -108,7 +108,7 @@ angular.module('pagerbot-admin')

console.log("Mass adding", expression, "for", selected_members, names, collection());
// slightly racy
$http.post('/normalize_strings', {strings: names})
$http.post('/api/normalize_strings', {strings: names})
.success(function(result) {
console.debug("Normalization results:", result);
_.each(_.zip(result.strings, selected_members), function(pair) {
Expand All @@ -131,4 +131,4 @@ angular.module('pagerbot-admin')

return service;
};
});
});

0 comments on commit f7912de

Please sign in to comment.