Skip to main content

get_profile_header

Function get_profile_header 

Source
pub fn get_profile_header(
    method: &str,
    headers: Option<&HashMap<String, String>>,
) -> Option<String>
Expand description

Gets the appropriate profile header based on HTTP method.

  • GET → Accept-Profile
  • POST/PATCH/DELETE → Content-Profile

§Examples

use postgrest_parser::parser::get_profile_header;
use std::collections::HashMap;

let mut headers = HashMap::new();
headers.insert("Accept-Profile".to_string(), "myschema".to_string());
let schema = get_profile_header("GET", Some(&headers));
assert_eq!(schema, Some("myschema".to_string()));

let mut headers = HashMap::new();
headers.insert("Content-Profile".to_string(), "auth".to_string());
let schema = get_profile_header("POST", Some(&headers));
assert_eq!(schema, Some("auth".to_string()));