     request(.DELETE, url: url, parameters: parameters, run: run)
   }
   
+  class func headers(fileName: String? = #file, funcName: String? = #function) -> [String: String] {
+    let appId = K.Api.appID
+    var headers_ = ["app_id": appId, "file_name": (fileName! as NSString).lastPathComponent, "func_name": funcName!]
+      headers_["Authorization"] = K.Api.userToken
+      headers_["token"] = (Session.getValueObject(K.Api.userTokenKey) as? String) ?? K.Api.userToken
+      if Development.Log.API.header { _logForAnyMode(headers_, title: "headers") }
+      return headers_
+  }
+  
   class public func request(method: Alamofire.Method = .GET, url: String, parameters: [String: AnyObject] = [:], fileName: String? = #file, funcName: String? = #function, run: (response: Response<AnyObject, NSError>) -> ()) {
-    
-    let appId = K.Api.appID
-    var headers = ["app_id": appId, "file_name": (fileName! as NSString).lastPathComponent, "func_name": funcName!]
-    headers["Authorization"] = K.Api.userToken
-    headers["token"] = (Session.getValueObject(K.Api.userTokenKey) as? String) ?? K.Api.userToken
-    if Development.Log.API.header { _logForAnyMode(headers, title: "headers") }
     _logForAnyMode(url.hostUrl(), title: "url.hostUrl()")
     if Development.Log.API.parameters { _logForAnyMode(parameters, title: "parameters") }
     let indicator = indicatorStart()
     let requestStartTime = NSDate()
     var requestTime: Double = 0
-    Alamofire.request(method, url.hostUrl(), parameters: parameters, headers: headers).responseJSON { response in
-      if Development.Log.API.request { _logForAnyMode(response.request!, title: "response.request") }
-      if Development.Log.API.statusCode { _logForAnyMode((response.response?.statusCode)!, title: "(response.response?.statusCode)!") }
-      if Development.Log.API.processInfo { print("NSProcessInfo.processInfo().environment: ", NSProcessInfo.processInfo().environment)}
+    
+    Alamofire.request(method, url.hostUrl(), parameters: parameters, headers: headers()).responseJSON { response in
       requestTime = NSDate().timeIntervalSinceDate(requestStartTime)
-      switch response.result {
-      case .Success(let value):
-        if Development.Log.API.response { _logForAnyMode(value, title: "response.result.value") }
-        if let items = value as? NSArray {
-          run(response: response)
-        } else if let item = value as? NSDictionary {
-          switch (response.response?.statusCode)! {
-          case 404:
-            prompt(value.objectForKey(K.Api.Response.message) as? String ?? "路徑錯誤!")
-          case 400:
-            prompt(value.objectForKey(K.Api.Response.message) as? String)
-          case 440:
-            prompt(value.objectForKey(K.Api.Response.message) as? String)
-            delayedJob({
-              appDelegate().redirectToLogin()
-            })
-          case 422:
-            prompt(value.objectForKey(K.Api.Response.message) as? String)
-          case 500:
-            prompt("伺服器內部錯誤，請稍後再試。")
-            appDelegate().did500Error()
-          default:
-            if let message = value.objectForKey(K.Api.Response.message) as? String {
-              if let text = message as? String {
-                prompt(text)
-              } else if let texts = message as? NSDictionary {
-                let text = texts.map{"\($0.key): \($0.value)"}.join("\n")
-                prompt(text)
-              } else {
-              }
-            }
-            run(response: response)
-          }
-        } else {
-          print(value, "value in API")
-          run(response: response)
-        }
-      case .Failure:
-        //        print("response:", response)
-        prompt((response.result.error?.localizedDescription)!)
-        //        #if DEBUG
-        //          prompt((response.result.error?.localizedDescription)!)
-        //        #else
-        //          if _isSimulator() {
-        //          }
-        //        #endif
-      }
+      processJSONResponse(response, run: run)
       indicatorEnd(indicator)
     }
     //    delayedJob(5) {

    }
  }
  
}


        case .Success(let upload, _, _):
          upload.responseJSON(completionHandler: onComplete)
        case .Failure(let error):
          //          prompt(result)
          break
        }
    })
