pub trait Lookup: Debug {
    // Required method
    fn lookup(&mut self, url: &Url) -> Url;
}
Expand description

Lookup

Intention with this lookup is primarily for testing by redirecting all requests to localhost (127.0.0.1) in combination with the port of mock server.

The url host, port and scheme will be swapped when building the request. No functionality is affected.

*Example: *

    #[derive(Debug)]
    struct CustomLookup;

    impl Lookup for CustomLookup {
         fn lookup(&mut self, _url: &Url) -> Url {
             Url::parse("http://your-test-url:1234").unwrap()
         }
    }

    RequestOptions {
        lookup: Some(Box::new(CustomLookup{})),
        ..Default::default()
    }

Required Methods§

source

fn lookup(&mut self, url: &Url) -> Url

The url with path (no query params) of the request url is passed as the url parameter in return expects a Url back.

  • The Scheme and host is required from the returned Url. Returns an error otherwise. Port is optional

  • The entire url is just passed for reference. Only the host:port will be replaced. Not the path.

Example:
    fn lookup(&mut self, _url: &Url) -> Url {
        Url::parse("http://your-test-url:1234").unwrap()
    }

Implementors§