@@ -116,7 +116,7 @@ impl MetricsIntakeUrlPrefix {
116
116
117
117
#[ inline]
118
118
fn from_site ( site : Site ) -> Self {
119
- Self ( format ! ( "https://api.{}" , site ) )
119
+ Self ( format ! ( "https://api.{site}" ) )
120
120
}
121
121
}
122
122
@@ -185,25 +185,23 @@ impl DdApi {
185
185
body : Vec < u8 > ,
186
186
content_type : & str ,
187
187
) -> Result < Response , ShippingError > {
188
- if let Some ( client) = & self . client {
189
- let start = std:: time:: Instant :: now ( ) ;
190
-
191
- let resp = client
192
- . post ( & url)
193
- . header ( "DD-API-KEY" , & self . api_key )
194
- . header ( "Content-Type" , content_type)
195
- . body ( body)
196
- . send ( )
197
- . await ;
198
-
199
- let elapsed = start. elapsed ( ) ;
200
- debug ! ( "Request to {} took {}ms" , url, elapsed. as_millis( ) ) ;
201
- resp. map_err ( |e| {
202
- ShippingError :: Destination ( e. status ( ) , format ! ( "Cannot reach {}" , url) )
203
- } )
204
- } else {
205
- Err ( ShippingError :: Destination ( None , "No client" . to_string ( ) ) )
206
- }
188
+ let client = & self
189
+ . client
190
+ . as_ref ( )
191
+ . ok_or_else ( || ShippingError :: Destination ( None , "No client" . to_string ( ) ) ) ?;
192
+ let start = std:: time:: Instant :: now ( ) ;
193
+
194
+ let resp = client
195
+ . post ( & url)
196
+ . header ( "DD-API-KEY" , & self . api_key )
197
+ . header ( "Content-Type" , content_type)
198
+ . body ( body)
199
+ . send ( )
200
+ . await ;
201
+
202
+ let elapsed = start. elapsed ( ) ;
203
+ debug ! ( "Request to {} took {}ms" , url, elapsed. as_millis( ) ) ;
204
+ resp. map_err ( |e| ShippingError :: Destination ( e. status ( ) , format ! ( "Cannot reach {url}" ) ) )
207
205
}
208
206
}
209
207
0 commit comments