mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Return http status 204 on deletes
Closes #2871 - Refactor api http handlers. - Update tests. - Remove special handling of responses in ember adapter.
This commit is contained in:
parent
aa4c72901c
commit
cf349b3be9
2 changed files with 16 additions and 16 deletions
|
@ -41,20 +41,6 @@ export default RESTAdapter.extend(DataAdapterMixin, {
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Override deleteRecord to disregard the response body on 2xx responses.
|
|
||||||
// This is currently needed because the API is returning status 200 along
|
|
||||||
// with the JSON object for the deleted entity and Ember expects an empty
|
|
||||||
// response body for successful DELETEs.
|
|
||||||
// Non-2xx (failure) responses will still work correctly as Ember will turn
|
|
||||||
// them into rejected promises.
|
|
||||||
deleteRecord() {
|
|
||||||
let response = this._super(...arguments);
|
|
||||||
|
|
||||||
return response.then(() => {
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
handleResponse(status) {
|
handleResponse(status) {
|
||||||
if (status === 401) {
|
if (status === 401) {
|
||||||
if (this.get('session.isAuthenticated')) {
|
if (this.get('session.isAuthenticated')) {
|
||||||
|
|
|
@ -125,6 +125,12 @@ export default function () {
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.del('/posts/:id/', function (db, request) {
|
||||||
|
db.posts.remove(request.params.id);
|
||||||
|
|
||||||
|
return new Mirage.Response(204, {}, {});
|
||||||
|
});
|
||||||
|
|
||||||
/* Roles ---------------------------------------------------------------- */
|
/* Roles ---------------------------------------------------------------- */
|
||||||
|
|
||||||
this.get('/roles/', function (db, request) {
|
this.get('/roles/', function (db, request) {
|
||||||
|
@ -267,7 +273,11 @@ export default function () {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.del('/tags/:id/', 'tag');
|
this.del('/tags/:id/', function (db, request) {
|
||||||
|
db.tags.remove(request.params.id);
|
||||||
|
|
||||||
|
return new Mirage.Response(204, {}, {});
|
||||||
|
});
|
||||||
|
|
||||||
/* Users ---------------------------------------------------------------- */
|
/* Users ---------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -304,7 +314,11 @@ export default function () {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.del('/users/:id/', 'user');
|
this.del('/users/:id/', function (db, request) {
|
||||||
|
db.users.remove(request.params.id);
|
||||||
|
|
||||||
|
return new Mirage.Response(204, {}, {});
|
||||||
|
});
|
||||||
|
|
||||||
this.get('/users/:id', function (db, request) {
|
this.get('/users/:id', function (db, request) {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Reference in a new issue