File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed
core/guard/server/src/routing Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -97,4 +97,19 @@ impl Datacenter {
9797 self . public_url . host_str ( ) == Some ( host)
9898 }
9999 }
100+
101+ pub fn public_url_host ( & self ) -> Result < & str > {
102+ self . public_url . host_str ( ) . context ( "no host" )
103+ }
104+
105+ pub fn public_url_port ( & self ) -> Result < u16 > {
106+ self . public_url
107+ . port ( )
108+ . or_else ( || match self . public_url . scheme ( ) {
109+ "http" => Some ( 80 ) ,
110+ "https" => Some ( 443 ) ,
111+ _ => None ,
112+ } )
113+ . context ( "unsupported URL scheme" )
114+ }
100115}
Original file line number Diff line number Diff line change @@ -76,14 +76,12 @@ pub async fn route_request(
7676 targets : vec ! [ RouteTarget {
7777 actor_id: Some ( actor_id) ,
7878 host: peer_dc
79- . public_url
80- . host( )
81- . context( "peer dc public_url has no host" ) ?
79+ . public_url_host( )
80+ . context( "bad peer dc public url host" ) ?
8281 . to_string( ) ,
8382 port: peer_dc
84- . public_url
85- . port( )
86- . context( "peer dc public_url has no port" ) ?,
83+ . public_url_port( )
84+ . context( "bad peer dc public url port" ) ?,
8785 path: path. to_owned( ) ,
8886 } ] ,
8987 timeout : RoutingTimeout {
You can’t perform that action at this time.
0 commit comments