From 2ca8c6d6b167d64193db0c1654fc2d455bca09a0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 14 Oct 2012 09:47:23 -0400 Subject: [PATCH] Do not send errors as part of the JSON response anymore. --- frontend/file.js | 7 +------ server/server.go | 27 ++++++++------------------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/frontend/file.js b/frontend/file.js index 6c8422b..60047fa 100644 --- a/frontend/file.js +++ b/frontend/file.js @@ -123,12 +123,7 @@ armadillo.File.prototype.createDom = function() { armadillo.File.prototype.remove = function() { var file = this; var callback = function(data, status, xhr) { - if (data['error']) { - app.showError(data['message']); - return; - } else { - app.clearError(); - } + app.clearError(); app.list(file.path_); }; app.sendRequest('remove', {'path':this.path_ + this.name_}, callback); diff --git a/server/server.go b/server/server.go index 3170113..d4bd3ac 100644 --- a/server/server.go +++ b/server/server.go @@ -47,6 +47,10 @@ func indexHandler(rw http.ResponseWriter, request *http.Request) { io.Copy(rw, fd) } +type pathReseponse struct { + Path string `json:"path"` +} + func listService(rw http.ResponseWriter, req *http.Request) { if !requestIsPOST(rw, req) { return @@ -69,10 +73,7 @@ func removeService(rw http.ResponseWriter, req *http.Request) { if err != nil { httpError(rw, err.Error(), http.StatusNotFound) } else { - data := map[string]int{ - "error": 0, - } - okResponse(rw, data) + okResponse(rw, nil) } } @@ -87,11 +88,7 @@ func moveService(rw http.ResponseWriter, req *http.Request) { if err != nil { httpError(rw, err.Error(), http.StatusNotFound) } else { - data := map[string]interface{}{ - "path": target, - "error": 0, - } - okResponse(rw, data) + okResponse(rw, pathReseponse{target}) } } @@ -105,11 +102,7 @@ func mkdirService(rw http.ResponseWriter, req *http.Request) { if err != nil { httpError(rw, err.Error(), http.StatusUnauthorized) } else { - data := map[string]interface{}{ - "path": path, - "error": 0, - } - okResponse(rw, data) + okResponse(rw, pathReseponse{path}) } } @@ -122,11 +115,7 @@ func tvRenameService(rw http.ResponseWriter, req *http.Request) { if err != nil { httpError(rw, err.Error(), http.StatusBadRequest) } else { - data := map[string]interface{}{ - "path": newPath, - "error": 0, - } - okResponse(rw, data) + okResponse(rw, pathReseponse{newPath}) } } -- 2.22.5