Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3780598
D2094.id5288.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D2094.id5288.diff
View Options
diff --git a/Cargo.toml b/Cargo.toml
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "limiting-factor"
-version = "0.6.0"
+version = "0.7.0"
authors = [
"Sébastien Santoro <dereckson@espace-win.org>",
]
diff --git a/src/api/replies.rs b/src/api/replies.rs
--- a/src/api/replies.rs
+++ b/src/api/replies.rs
@@ -134,6 +134,33 @@
}
}
+/* -------------------------------------------------------------
+ API Delete Response
+
+ :: Implementation for QueryResult (Diesel ORM)
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+#[cfg(feature = "pgsql")]
+/// This trait allows to consume an object into an HTTP response.
+///
+/// This response is a odd case for DELETE queries, which return
+/// a scalar with the rows deleted count value, or an error.
+pub trait ApiDeleteResponse<T> {
+ /// Consumes the value and creates a JSON or a Status result response.
+ fn into_delete_json_response(self) -> ApiJsonResponse<()>;
+}
+
+#[cfg(feature = "pgsql")]
+impl ApiDeleteResponse<usize> for QueryResult<usize> {
+ fn into_delete_json_response(self) -> ApiJsonResponse<()> {
+ match self {
+ Ok(0) => Err(Status::NotFound),
+ Ok(1) => Ok(Json(())),
+ _ => Err(Status::BadRequest),
+ }
+ }
+}
+
/* -------------------------------------------------------------
Failure response
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 15:40 (21 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2264773
Default Alt Text
D2094.id5288.diff (1 KB)
Attached To
Mode
D2094: Allow to craft a JSON response for DELETE SQL queries
Attached
Detach File
Event Timeline
Log In to Comment