RESTful API

This commit is contained in:
Ricardo Tomasi 2013-05-24 09:17:46 -03:00
parent 3adbbebc45
commit 0d8866bc8e
3 changed files with 8 additions and 8 deletions

8
app.js
View File

@ -63,13 +63,13 @@
* @todo auth should be public auth not user auth
*/
ghost.app().get('/api/v0.1/posts', auth, api.requestHandler(api.posts.browse));
ghost.app().post('/api/v0.1/posts', auth, api.requestHandler(api.posts.add));
ghost.app().get('/api/v0.1/posts/:id', auth, api.requestHandler(api.posts.read));
ghost.app().post('/api/v0.1/posts/create', auth, api.requestHandler(api.posts.add));
ghost.app().put('/api/v0.1/posts/edit', auth, api.requestHandler(api.posts.edit));
ghost.app()['delete']('/api/v0.1/posts/:id', auth, api.requestHandler(api.posts.destroy));
ghost.app().put('/api/v0.1/posts/:id', auth, api.requestHandler(api.posts.edit));
ghost.app().del('/api/v0.1/posts/:id', auth, api.requestHandler(api.posts.destroy));
ghost.app().get('/api/v0.1/settings', auth, api.requestHandler(api.settings.browse));
ghost.app().get('/api/v0.1/settings/:key', auth, api.requestHandler(api.settings.read));
ghost.app().put('/api/v0.1/settings/edit', auth, api.requestHandler(api.settings.edit));
ghost.app().put('/api/v0.1/settings', auth, api.requestHandler(api.settings.edit));
/**
* Admin routes..

View File

@ -61,9 +61,9 @@
urlSegments = window.location.pathname.split('/');
if (urlSegments[2] === 'editor' && urlSegments[3] && /^[a-zA-Z0-9]+$/.test(urlSegments[2])) {
entry.id = urlSegments[3];
var id = urlSegments[3];
$.ajax({
url: '/api/v0.1/posts/edit',
url: '/api/v0.1/posts/' + id,
method: 'PUT',
data: entry,
success: function (data) {
@ -75,7 +75,7 @@
});
} else {
$.ajax({
url: '/api/v0.1/posts/create',
url: '/api/v0.1/posts',
method: 'POST',
data: entry,
success: function (data) {

View File

@ -48,7 +48,7 @@
var data = getSettings();
$.ajax({
method: 'PUT',
url: '/api/v0.1/settings/edit',
url: '/api/v0.1/settings',
data: data,
success: function (res, xhr, c) {
console.log(xhr, c);