pub trait HeaderMapExt {
    // Required method
    fn get_str(&self, key: &str) -> Option<&str>;

    // Provided methods
    fn get_host(&self) -> Option<&str> { ... }
    fn get_client_ip(&self) -> Option<IpAddr> { ... }
    fn get_content_type(&self) -> Option<&str> { ... }
    fn has_json_content_type(&self) -> bool { ... }
}
Expand description

Extension trait for HeaderMap.

Required Methods§

source

fn get_str(&self, key: &str) -> Option<&str>

Ges the string corresponding to the key.

Provided Methods§

source

fn get_host(&self) -> Option<&str>

Gets the destination host.

It is determined in the following priority:

  1. Forwarded header host key
  2. The first X-Forwarded-Host header
  3. Host header
source

fn get_client_ip(&self) -> Option<IpAddr>

Gets the client’s remote IP.

It is determined in the following priority:

  1. Forwarded header for key
  2. The first X-Forwarded-For header
  3. The first X-Real-Ip header
source

fn get_content_type(&self) -> Option<&str>

Gets the essence of the content-type header, discarding the optional parameters.

source

fn has_json_content_type(&self) -> bool

Checks whether it has a content-type: application/json or similar header.

Implementations on Foreign Types§

source§

impl HeaderMapExt for HeaderMap

source§

fn get_str(&self, key: &str) -> Option<&str>

Implementors§