@@ -5,7 +5,7 @@ pub async fn json(ctx: Context) {
55 "message" : RESPONSEDATA_STR
66 } ) ;
77 let run = || async {
8- ctx. set_response_body ( serde_json:: to_string ( & json) . unwrap_or_default ( ) )
8+ ctx. set_response_body ( & serde_json:: to_vec ( & json) . unwrap_or_default ( ) )
99 . await ;
1010 ctx. send ( ) . await . unwrap ( ) ;
1111 } ;
@@ -18,7 +18,7 @@ pub async fn json(ctx: Context) {
1818
1919pub async fn plaintext ( ctx : Context ) {
2020 ctx. set_response_header ( CONTENT_TYPE , TEXT_PLAIN ) . await ;
21- ctx. set_response_body ( RESPONSEDATA_BIN ) . await ;
21+ ctx. set_response_body ( & RESPONSEDATA_BIN ) . await ;
2222 let run = || async {
2323 ctx. send ( ) . await . unwrap ( ) ;
2424 } ;
@@ -33,7 +33,7 @@ pub async fn db(ctx: Context) {
3333 let db_connection: & DbPoolConnection = get_db_connection ( ) ;
3434 let run = || async {
3535 let query_row: QueryRow = random_world_row ( db_connection) . await ;
36- ctx. set_response_body ( serde_json:: to_string ( & query_row) . unwrap_or_default ( ) )
36+ ctx. set_response_body ( & serde_json:: to_vec ( & query_row) . unwrap_or_default ( ) )
3737 . await
3838 . send ( )
3939 . await
@@ -57,7 +57,7 @@ pub async fn query(ctx: Context) {
5757 . max ( 1 ) ;
5858 let db_pool: & DbPoolConnection = get_db_connection ( ) ;
5959 let data: Vec < QueryRow > = get_some_row_id ( queries, db_pool) . await ;
60- ctx. set_response_body ( serde_json:: to_string ( & data) . unwrap_or_default ( ) )
60+ ctx. set_response_body ( & serde_json:: to_vec ( & data) . unwrap_or_default ( ) )
6161 . await
6262 . send ( )
6363 . await
@@ -73,7 +73,7 @@ pub async fn query(ctx: Context) {
7373pub async fn fortunes ( ctx : Context ) {
7474 ctx. set_response_header (
7575 CONTENT_TYPE ,
76- ContentType :: format_content_type_with_charset ( TEXT_HTML , UTF8 ) ,
76+ & ContentType :: format_content_type_with_charset ( TEXT_HTML , UTF8 ) ,
7777 )
7878 . await ;
7979 let run = || async {
@@ -92,7 +92,7 @@ pub async fn fortunes(ctx: Context) {
9292 ) ) ;
9393 fortunes_list. sort_by ( |it, next| it. message . cmp ( & next. message ) ) ;
9494 let res: String = FortunesTemplate :: new ( fortunes_list) . to_string ( ) ;
95- ctx. set_response_body ( res) . await . send ( ) . await . unwrap ( ) ;
95+ ctx. set_response_body ( & res) . await . send ( ) . await . unwrap ( ) ;
9696 } ;
9797 run ( ) . await ;
9898 while let Ok ( _) = ctx. http_from_stream ( HTTP_BUFFER ) . await {
@@ -111,7 +111,7 @@ pub async fn update(ctx: Context) {
111111 . min ( ROW_LIMIT as Queries )
112112 . max ( 1 ) ;
113113 let res: Vec < QueryRow > = update_world_rows ( queries) . await ;
114- ctx. set_response_body ( serde_json:: to_string ( & res) . unwrap_or_default ( ) )
114+ ctx. set_response_body ( & serde_json:: to_vec ( & res) . unwrap_or_default ( ) )
115115 . await
116116 . send ( )
117117 . await
@@ -134,7 +134,7 @@ pub async fn cached_query(ctx: Context) {
134134 . min ( ROW_LIMIT as Queries )
135135 . max ( 1 ) ;
136136 let res: Vec < & QueryRow > = CACHE . iter ( ) . take ( count as usize ) . collect ( ) ;
137- ctx. set_response_body ( serde_json:: to_string ( & res) . unwrap_or_default ( ) )
137+ ctx. set_response_body ( & serde_json:: to_vec ( & res) . unwrap_or_default ( ) )
138138 . await
139139 . send ( )
140140 . await
0 commit comments