fn handler_for_host_path(
        &self,
        host: &str,
        uri_fragment: &str,
    ) -> Result<Handler, anyhow::Error> {
        log::trace!(
            "Module::handler_for_host_path: host={}, url_fragment={}",
            host,
            uri_fragment
        );
        let default_host = self
            .default_host
            .clone()
            .unwrap_or_else(|| DEFAULT_HOST.to_owned());
        if let Some(routes) = self.route_cache.as_ref() {
            for r in routes {
                log::trace!(
                    "Module::handler_for_host_path: trying route host={:?} path={}",
                    r.host(),
                    r.path
                );
                // The request must match either the `host` of an entry or the `default_host`
                // for this server.
                match r.host() {
                    // Host doesn't match. Skip.
                    Some(h) if h != host => {
                        log::trace!("Module::handler_for_host_path: host {} did not match", h);
                        continue;
                    }
                    // This is not the default domain. Skip.
                    None if !is_default_host(default_host.as_str(), host) => {
                        log::trace!(
                            "Module::handler_for_host_path: default host {} did not match",
                            default_host
                        );
                        continue;
                    }
                    // Something matched, so continue our checks.
                    _ => {}
                }
                log::trace!("Module::handler_for_host_path: host matched, examining path");
                // The important detail here is that strip_suffix returns None if the suffix
                // does not exist. So ONLY paths that end with /... are substring-matched.
                if r.path
                    .strip_suffix("/...")
                    .map(|i| {
                        log::info!("Comparing {} to {}", uri_fragment.clone(), r.path.as_str());
                        uri_fragment.starts_with(i)
                    })
                    .unwrap_or_else(|| r.path == uri_fragment)
                {
                    return Ok(r.clone());
                }
            }
        }

        Err(anyhow::anyhow!("No handler for //{}{}", host, uri_fragment))
    }
/// Given a URI fragment, find the handler that can execute this.
Given a URI fragment, find the handler that can execute this.
Given a URI fragment find the handler that can execute this .
fn handler_for_host_path(
        &self,
        host: &str,
        uri_fragment: &str,
    ) -> Result<Handler, anyhow::Error> {
        log::trace!(
            "Module::handler_for_host_path: host={}, url_fragment={}",
            host,
            uri_fragment
        );
        let default_host = self
            .default_host
            .clone()
            .unwrap_or_else(|| DEFAULT_HOST.to_owned());
        if let Some(routes) = self.route_cache.as_ref() {
            for r in routes {
                log::trace!(
                    "Module::handler_for_host_path: trying route host={:?} path={}",
                    r.host(),
                    r.path
                );
                // The request must match either the `host` of an entry or the `default_host`
                // for this server.
                match r.host() {
                    // Host doesn't match. Skip.
                    Some(h) if h != host => {
                        log::trace!("Module::handler_for_host_path: host {} did not match", h);
                        continue;
                    }
                    // This is not the default domain. Skip.
                    None if !is_default_host(default_host.as_str(), host) => {
                        log::trace!(
                            "Module::handler_for_host_path: default host {} did not match",
                            default_host
                        );
                        continue;
                    }
                    // Something matched, so continue our checks.
                    _ => {}
                }
                log::trace!("Module::handler_for_host_path: host matched, examining path");
                // The important detail here is that strip_suffix returns None if the suffix
                // does not exist. So ONLY paths that end with /... are substring-matched.
                if r.path
                    .strip_suffix("/...")
                    .map(|i| {
                        log::info!("Comparing {} to {}", uri_fragment.clone(), r.path.as_str());
                        uri_fragment.starts_with(i)
                    })
                    .unwrap_or_else(|| r.path == uri_fragment)
                {
                    return Ok(r.clone());
                }
            }
        }
        Err(anyhow::anyhow!("No handler for //{}{}", host, uri_fragment))
    }
fn handler_for_host_path ( & self , host : & str , uri_fragment : & str , ) -> Result < Handler , anyhow :: Error > { log :: trace ! ( " " host uri_fragment ) ; let default_host = self . default_host . clone ( ) . unwrap_or_else ( | | DEFAULT_HOST . to_owned ( ) ) ; if let Some ( routes ) = self . route_cache . as_ref ( ) { for r in routes { log :: trace ! ( " " r host ( ) r path ) ; // The request must match either the `host` of an entry or the `default_host` // for this server. match r . host ( ) { // Host doesn't match. Skip. Some ( h ) if h != host => { log :: trace ! ( " " h ) ; continue ; } // This is not the default domain. Skip. None if ! is_default_host ( default_host . as_str ( ) , host ) => { log :: trace ! ( " " default_host ) ; continue ; } // Something matched, so continue our checks. _ => { } } log :: trace ! ( " " ) ; // The important detail here is that strip_suffix returns None if the suffix // does not exist. So ONLY paths that end with /... are substring-matched. if r . path . strip_suffix ( " " ) . map ( | i | { log :: info ! ( " " uri_fragment clone ( ) r path as_str ( ) ) ; uri_fragment . starts_with ( i ) } ) . unwrap_or_else ( | | r . path == uri_fragment ) { return Ok ( r . clone ( ) ) ; } } } Err ( anyhow :: anyhow ! ( " " host uri_fragment ) ) }
Given a URI fragment, find the handler that can execute this.
Given a URI fragment find the handler that can execute this .
&self
host
&str
uri_fragment
&str