0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

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 * @todo auth should be public auth not user auth
*/ */
ghost.app().get('/api/v0.1/posts', auth, api.requestHandler(api.posts.browse)); 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().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/:id', auth, api.requestHandler(api.posts.edit));
ghost.app().put('/api/v0.1/posts/edit', auth, api.requestHandler(api.posts.edit)); ghost.app().del('/api/v0.1/posts/:id', auth, api.requestHandler(api.posts.destroy));
ghost.app()['delete']('/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', auth, api.requestHandler(api.settings.browse));
ghost.app().get('/api/v0.1/settings/:key', auth, api.requestHandler(api.settings.read)); 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.. * Admin routes..

View file

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

View file

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