aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--src/database.rs4
-rw-r--r--src/main.rs2
3 files changed, 4 insertions, 4 deletions
diff --git a/README.md b/README.md
index 95e8f7e..e2e6948 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ Pings the server
GET `/create_user/<name>`
Creates a new user with name
- Return type: JSON
-- Returns: <user>
+- Returns: <user_id>
GET `/get_user/<id>`
Gets a user from id
diff --git a/src/database.rs b/src/database.rs
index 8c26844..af7de68 100644
--- a/src/database.rs
+++ b/src/database.rs
@@ -165,7 +165,7 @@ impl Database {
None
}
- pub fn create_user(&mut self, name: String) -> Result<(), &'static str> {
+ pub fn create_user(&mut self, name: String) -> Result<usize, &'static str> {
let id = self.get_user_count();
let query = "INSERT INTO users (id, username) VALUES (:id, :name)";
@@ -184,7 +184,7 @@ impl Database {
}
}
- Ok(())
+ Ok(id)
}
pub fn get_user_count(&self) -> usize {
diff --git a/src/main.rs b/src/main.rs
index a9db22e..3e12e1f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -96,7 +96,7 @@ fn get_user_by_name(name: String, db: &State<SharedDB>) -> Json<Response<User, &
}
}
#[get("/create_user/<name>")]
-fn create_user(name: String, db: &State<SharedDB>) -> Json<Response<(), &'static str>> {
+fn create_user(name: String, db: &State<SharedDB>) -> Json<Response<usize, &'static str>> {
let mut lock = db.sdb.lock().unwrap();
Json(Response(lock.create_user(name)))