|
@@ -5,19 +5,23 @@ pub async fn json(ctx: Context) {
|
|
|
"message": RESPONSEDATA_STR
|
|
|
});
|
|
|
let _ = ctx
|
|
|
- .send_response(200, serde_json::to_string(&json).unwrap_or_default())
|
|
|
+ .set_response_body(serde_json::to_string(&json).unwrap_or_default())
|
|
|
+ .await
|
|
|
+ .send()
|
|
|
.await;
|
|
|
}
|
|
|
|
|
|
pub async fn plaintext(ctx: Context) {
|
|
|
- let _ = ctx.send_response(200, RESPONSEDATA_BIN).await;
|
|
|
+ let _ = ctx.set_response_body(RESPONSEDATA_BIN).await.send().await;
|
|
|
}
|
|
|
|
|
|
pub async fn db(ctx: Context) {
|
|
|
let db_connection: &DbPoolConnection = get_db_connection();
|
|
|
let query_row: QueryRow = random_world_row(db_connection).await;
|
|
|
let _ = ctx
|
|
|
- .send_response(200, serde_json::to_string(&query_row).unwrap_or_default())
|
|
|
+ .set_response_body(serde_json::to_string(&query_row).unwrap_or_default())
|
|
|
+ .await
|
|
|
+ .send()
|
|
|
.await;
|
|
|
}
|
|
|
|
|
@@ -32,7 +36,9 @@ pub async fn query(ctx: Context) {
|
|
|
let db_pool: &DbPoolConnection = get_db_connection();
|
|
|
let data: Vec<QueryRow> = get_some_row_id(queries, db_pool).await;
|
|
|
let _ = ctx
|
|
|
- .send_response(200, serde_json::to_string(&data).unwrap_or_default())
|
|
|
+ .set_response_body(serde_json::to_string(&data).unwrap_or_default())
|
|
|
+ .await
|
|
|
+ .send()
|
|
|
.await;
|
|
|
}
|
|
|
|
|
@@ -52,7 +58,7 @@ pub async fn fortunes(ctx: Context) {
|
|
|
));
|
|
|
fortunes_list.sort_by(|it, next| it.message.cmp(&next.message));
|
|
|
let res: String = FortunesTemplate::new(fortunes_list).to_string();
|
|
|
- let _ = ctx.send_response(200, res).await;
|
|
|
+ let _ = ctx.set_response_body(res).await.send().await;
|
|
|
}
|
|
|
|
|
|
pub async fn update(ctx: Context) {
|
|
@@ -65,7 +71,9 @@ pub async fn update(ctx: Context) {
|
|
|
.max(1);
|
|
|
let res: Vec<QueryRow> = update_world_rows(queries).await;
|
|
|
let _ = ctx
|
|
|
- .send_response(200, serde_json::to_string(&res).unwrap_or_default())
|
|
|
+ .set_response_body(serde_json::to_string(&res).unwrap_or_default())
|
|
|
+ .await
|
|
|
+ .send()
|
|
|
.await;
|
|
|
}
|
|
|
|
|
@@ -79,6 +87,8 @@ pub async fn cached_query(ctx: Context) {
|
|
|
.max(1);
|
|
|
let res: Vec<QueryRow> = CACHE.iter().take(count as usize).cloned().collect();
|
|
|
let _ = ctx
|
|
|
- .send_response(200, serde_json::to_string(&res).unwrap_or_default())
|
|
|
+ .set_response_body(serde_json::to_string(&res).unwrap_or_default())
|
|
|
+ .await
|
|
|
+ .send()
|
|
|
.await;
|
|
|
}
|