@@ -5,19 +5,23 @@ pub async fn json(ctx: Context) {
55 "message" : RESPONSEDATA_STR
66 } ) ;
77 let _ = ctx
8- . send_response ( 200 , serde_json:: to_string ( & json) . unwrap_or_default ( ) )
8+ . set_response_body ( serde_json:: to_string ( & json) . unwrap_or_default ( ) )
9+ . await
10+ . send ( )
911 . await ;
1012}
1113
1214pub async fn plaintext ( ctx : Context ) {
13- let _ = ctx. send_response ( 200 , RESPONSEDATA_BIN ) . await ;
15+ let _ = ctx. set_response_body ( RESPONSEDATA_BIN ) . await . send ( ) . await ;
1416}
1517
1618pub async fn db ( ctx : Context ) {
1719 let db_connection: & DbPoolConnection = get_db_connection ( ) ;
1820 let query_row: QueryRow = random_world_row ( db_connection) . await ;
1921 let _ = ctx
20- . send_response ( 200 , serde_json:: to_string ( & query_row) . unwrap_or_default ( ) )
22+ . set_response_body ( serde_json:: to_string ( & query_row) . unwrap_or_default ( ) )
23+ . await
24+ . send ( )
2125 . await ;
2226}
2327
@@ -32,7 +36,9 @@ pub async fn query(ctx: Context) {
3236 let db_pool: & DbPoolConnection = get_db_connection ( ) ;
3337 let data: Vec < QueryRow > = get_some_row_id ( queries, db_pool) . await ;
3438 let _ = ctx
35- . send_response ( 200 , serde_json:: to_string ( & data) . unwrap_or_default ( ) )
39+ . set_response_body ( serde_json:: to_string ( & data) . unwrap_or_default ( ) )
40+ . await
41+ . send ( )
3642 . await ;
3743}
3844
@@ -52,7 +58,7 @@ pub async fn fortunes(ctx: Context) {
5258 ) ) ;
5359 fortunes_list. sort_by ( |it, next| it. message . cmp ( & next. message ) ) ;
5460 let res: String = FortunesTemplate :: new ( fortunes_list) . to_string ( ) ;
55- let _ = ctx. send_response ( 200 , res) . await ;
61+ let _ = ctx. set_response_body ( res) . await . send ( ) . await ;
5662}
5763
5864pub async fn update ( ctx : Context ) {
@@ -65,7 +71,9 @@ pub async fn update(ctx: Context) {
6571 . max ( 1 ) ;
6672 let res: Vec < QueryRow > = update_world_rows ( queries) . await ;
6773 let _ = ctx
68- . send_response ( 200 , serde_json:: to_string ( & res) . unwrap_or_default ( ) )
74+ . set_response_body ( serde_json:: to_string ( & res) . unwrap_or_default ( ) )
75+ . await
76+ . send ( )
6977 . await ;
7078}
7179
@@ -79,6 +87,8 @@ pub async fn cached_query(ctx: Context) {
7987 . max ( 1 ) ;
8088 let res: Vec < QueryRow > = CACHE . iter ( ) . take ( count as usize ) . cloned ( ) . collect ( ) ;
8189 let _ = ctx
82- . send_response ( 200 , serde_json:: to_string ( & res) . unwrap_or_default ( ) )
90+ . set_response_body ( serde_json:: to_string ( & res) . unwrap_or_default ( ) )
91+ . await
92+ . send ( )
8393 . await ;
8494}
0 commit comments