@@ -9,33 +9,33 @@ use crate::{error, serialization, ChunkedQuery, Node, Point, Points, Precision,
99/// The client to influxdb
1010#[ derive( Debug , Clone ) ]
1111pub struct Client {
12- host : String ,
12+ host : Url ,
1313 db : String ,
1414 authentication : Option < ( String , String ) > ,
1515 client : HttpClient ,
1616}
1717
1818impl Client {
1919 /// Create a new influxdb client with http
20- pub fn new < T > ( host : T , db : T ) -> Self
20+ pub fn new < T > ( host : Url , db : T ) -> Self
2121 where
2222 T : Into < String > ,
2323 {
2424 Client {
25- host : host . into ( ) ,
25+ host,
2626 db : db. into ( ) ,
2727 authentication : None ,
2828 client : HttpClient :: default ( ) ,
2929 }
3030 }
3131
3232 /// Create a new influxdb client with custom reqwest's client.
33- pub fn new_with_client < T > ( host : T , db : T , client : HttpClient ) -> Self
33+ pub fn new_with_client < T > ( host : Url , db : T , client : HttpClient ) -> Self
3434 where
3535 T : Into < String > ,
3636 {
3737 Client {
38- host : host . into ( ) ,
38+ host,
3939 db : db. into ( ) ,
4040 authentication : None ,
4141 client,
@@ -452,7 +452,7 @@ impl Client {
452452
453453 /// Constructs the full URL for an API call.
454454 fn build_url ( & self , key : & str , param : Option < Vec < ( & str , & str ) > > ) -> Url {
455- let url = Url :: parse ( & self . host ) . unwrap ( ) . join ( key) . unwrap ( ) ;
455+ let url = self . host . join ( key) . unwrap ( ) ;
456456
457457 let mut authentication = Vec :: new ( ) ;
458458
@@ -474,7 +474,7 @@ impl Client {
474474impl Default for Client {
475475 /// connecting for default database `test` and host `http://localhost:8086`
476476 fn default ( ) -> Self {
477- Client :: new ( "http://localhost:8086" , "test" )
477+ Client :: new ( Url :: parse ( "http://localhost:8086" ) . unwrap ( ) , "test" )
478478 }
479479}
480480
0 commit comments