1
1
use crate :: api:: post:: Post ;
2
2
use crate :: blog_backend;
3
- use crate :: infra:: http:: { body_or_err, RequestBuilderExt , VecExt } ;
3
+ use crate :: infra:: http:: { body_or_err, RequestBuilderExt } ;
4
4
use crate :: infra:: iter:: IntoIteratorExt ;
5
5
use crate :: infra:: json;
6
6
use crate :: infra:: result:: IntoResult ;
@@ -22,15 +22,14 @@ impl Post {
22
22
// If index is greater than the max page index, API will still return the last page
23
23
let total_count = {
24
24
let req = {
25
- let query = vec ! [
26
- ( "t" , "1" . to_string( ) ) ,
25
+ let url = blog_backend ! ( "/posts/list" ) ;
26
+ let query = [
27
+ ( "t" , 1 . to_string ( ) ) ,
27
28
( "p" , 1 . to_string ( ) ) ,
28
29
( "s" , 1 . to_string ( ) ) ,
29
30
( "search" , keyword. to_string ( ) ) ,
30
- ]
31
- . into_query_string ( ) ;
32
- let url = blog_backend ! ( "/posts/list?{}" , query) ;
33
- client. get ( url) . pat_auth ( & self . pat )
31
+ ] ;
32
+ client. get ( url) . query ( & query) . pat_auth ( & self . pat )
34
33
} ;
35
34
let resp = req. send ( ) . await ?;
36
35
@@ -48,15 +47,14 @@ impl Post {
48
47
let id_list = range
49
48
. map ( |i| async move {
50
49
let req = {
51
- let query = vec ! [
52
- ( "t" , "1" . to_string( ) ) ,
50
+ let url = blog_backend ! ( "/posts/list" ) ;
51
+ let query = [
52
+ ( "t" , 1 . to_string ( ) ) ,
53
53
( "p" , i. to_string ( ) ) ,
54
54
( "s" , 1 . to_string ( ) ) ,
55
55
( "search" , keyword. to_string ( ) ) ,
56
- ]
57
- . into_query_string ( ) ;
58
- let url = blog_backend ! ( "/posts/list?{}" , query) ;
59
- client. get ( url) . pat_auth ( & self . pat )
56
+ ] ;
57
+ client. get ( url) . query ( & query) . pat_auth ( & self . pat )
60
58
} ;
61
59
let resp = req. send ( ) . await ?;
62
60
0 commit comments