diff options
author | Yigit Sever | 2021-04-09 14:43:25 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-09 14:43:25 +0300 |
commit | 336a5b699604f11e223ae6fb111b88b9f9275bf1 (patch) | |
tree | 56c0bc7d10314bae8d7208b18321d37173f0d4f0 | |
parent | 84d9c14a17e864058527981e3388cef148827c11 (diff) | |
download | gradecoin-336a5b699604f11e223ae6fb111b88b9f9275bf1.tar.gz gradecoin-336a5b699604f11e223ae6fb111b88b9f9275bf1.tar.bz2 gradecoin-336a5b699604f11e223ae6fb111b88b9f9275bf1.zip |
Cleared unused code from handlers
The original repo is here: https://github.com/blurbyte/restful-rust
-rw-r--r-- | src/handlers.rs | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/src/handlers.rs b/src/handlers.rs index ecf5a92..856970d 100644 --- a/src/handlers.rs +++ b/src/handlers.rs | |||
@@ -88,83 +88,3 @@ pub async fn propose_block(new_block: Block, db: Db) -> Result<impl warp::Reply, | |||
88 | 88 | ||
89 | Ok(StatusCode::CREATED) | 89 | Ok(StatusCode::CREATED) |
90 | } | 90 | } |
91 | |||
92 | // `GET /games` | ||
93 | // Returns JSON array of todos | ||
94 | // Allows pagination, for example: `GET /games?offset=10&limit=5` | ||
95 | // pub async fn list_games(options: ListOptions, db: Db) -> Result<impl Reply, Infallible> { | ||
96 | // debug!("list all games"); | ||
97 | |||
98 | // let games = db.lock().await; | ||
99 | // let games: Vec<Game> = games | ||
100 | // .clone() | ||
101 | // .into_iter() | ||
102 | // .skip(options.offset.unwrap_or(0)) | ||
103 | // .take(options.limit.unwrap_or(std::usize::MAX)) | ||
104 | // .collect(); | ||
105 | |||
106 | // Ok(warp::reply::json(&games)) | ||
107 | // } | ||
108 | |||
109 | // `POST /games` | ||
110 | // Create new game entry with JSON body | ||
111 | // pub async fn create_game(new_game: Game, db: Db) -> Result<impl Reply, Infallible> { | ||
112 | // debug!("create new game: {:?}", new_game); | ||
113 | |||
114 | // let mut games = db.lock().await; | ||
115 | |||
116 | // match games.iter().find(|game| game.id == new_game.id) { | ||
117 | // Some(game) => { | ||
118 | // debug!("game of given id already exists: {}", game.id); | ||
119 | |||
120 | // Ok(StatusCode::BAD_REQUEST) | ||
121 | // } | ||
122 | // None => { | ||
123 | // games.push(new_game); | ||
124 | // Ok(StatusCode::CREATED) | ||
125 | // } | ||
126 | // } | ||
127 | // } | ||
128 | |||
129 | // `PUT /games/:id` | ||
130 | // pub async fn update_game(id: u64, updated_game: Game, db: Db) -> Result<impl Reply, Infallible> { | ||
131 | // debug!("update existing game: id={}, game={:?}", id, updated_game); | ||
132 | |||
133 | // let mut games = db.lock().await; | ||
134 | |||
135 | // match games.iter_mut().find(|game| game.id == id) { | ||
136 | // Some(game) => { | ||
137 | // *game = updated_game; | ||
138 | |||
139 | // Ok(StatusCode::OK) | ||
140 | // } | ||
141 | // None => { | ||
142 | // debug!("game of given id not found"); | ||
143 | |||
144 | // Ok(StatusCode::NOT_FOUND) | ||
145 | // } | ||
146 | // } | ||
147 | // } | ||
148 | |||
149 | // `DELETE /games/:id` | ||
150 | // pub async fn delete_game(id: u64, db: Db) -> Result<impl Reply, Infallible> { | ||
151 | // debug!("delete game: id={}", id); | ||
152 | |||
153 | // let mut games = db.lock().await; | ||
154 | |||
155 | // let len = games.len(); | ||
156 | |||
157 | // // Removes all games with given id | ||
158 | // games.retain(|game| game.id != id); | ||
159 | |||
160 | // // If games length was smaller that means specyfic game was found and removed | ||
161 | // let deleted = games.len() != len; | ||
162 | |||
163 | // if deleted { | ||
164 | // Ok(StatusCode::NO_CONTENT) | ||
165 | // } else { | ||
166 | // debug!("game of given id not found"); | ||
167 | |||
168 | // Ok(StatusCode::NOT_FOUND) | ||
169 | // } | ||
170 | // } | ||