File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,20 @@ impl Client {
3131 /// Construct a new producer client.
3232 ///
3333 /// `host` is where the `/producer/...` endpoints can be reached over http.
34- /// Don't include the scheme or the `/producer` part.
34+ /// You can include the scheme if it's `http://` or `https://`. If it's not
35+ /// included, http is chosen by default. If it's not supported, this function
36+ /// panics.
3537 ///
36- /// Examples: `0.0.0.0:1312`, `my.opsueue .instance.example.com`, `services.example.com/opsqueue`
38+ /// Examples: `0.0.0.0:1312`, `my.opsqueue .instance.example.com`, `https:// services.example.com/opsqueue`
3739 pub fn new ( host : & str ) -> Self {
3840 let http_client = reqwest:: Client :: new ( ) ;
39- let base_url = format ! ( "http://{host}/producer" ) . into_boxed_str ( ) ;
41+ let base_url = match host. split_once ( "://" ) {
42+ Some ( ( "http" | "https" , _) ) => format ! ( "{host}/producer" ) ,
43+ None => format ! ( "http://{host}/producer" ) ,
44+ Some ( ( scheme, _) ) => panic ! ( "Unsupported scheme: {scheme}, must be 'http' or 'https'" ) ,
45+ } ;
4046 Client {
41- base_url,
47+ base_url : base_url . into_boxed_str ( ) ,
4248 http_client,
4349 }
4450 }
You can’t perform that action at this time.
0 commit comments