pub fn resolve_schema(
table: &str,
method: &str,
headers: Option<&HashMap<String, String>>,
) -> Result<ResolvedTable, Error>Expand description
Resolves the schema and table name from various sources with priority:
- Explicit schema in table name (e.g., “auth.users”)
- Header-based (Accept-Profile for GET, Content-Profile for POST/PATCH/DELETE)
- Default “public” schema
§Arguments
table- Table name, optionally schema-qualified (e.g., “users” or “auth.users”)method- HTTP method (GET, POST, PATCH, DELETE)headers- Optional headers map containing profile headers
§Examples
use postgrest_parser::parser::resolve_schema;
use std::collections::HashMap;
// Explicit schema in table name
let table = resolve_schema("auth.users", "GET", None).unwrap();
assert_eq!(table.schema, "auth");
assert_eq!(table.name, "users");
// Header-based schema
let mut headers = HashMap::new();
headers.insert("Accept-Profile".to_string(), "myschema".to_string());
let table = resolve_schema("users", "GET", Some(&headers)).unwrap();
assert_eq!(table.schema, "myschema");
// Default public schema
let table = resolve_schema("users", "POST", None).unwrap();
assert_eq!(table.schema, "public");