Do not send errors as part of the JSON response anymore.
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 14 Oct 2012 13:47:23 +0000 (09:47 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 14 Oct 2012 13:47:23 +0000 (09:47 -0400)
frontend/file.js
server/server.go

index 6c8422b2887ca4e14de0da90b789e4eed08064d7..60047fa22aeab0aa1ddbc0986f9a00b9818a3282 100644 (file)
@@ -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);
index 31701135beaf60fb52776f408b4e4768a9308df3..d4bd3ac6b714efd082f5387fcd97f23ca7ce1823 100644 (file)
@@ -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})
        }
 }