systemprompt-oauth 0.1.22

OAuth 2.0 authentication and authorization module for systemprompt.io OS
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use http::HeaderMap;

pub fn is_browser_request(headers: &HeaderMap) -> bool {
    headers
        .get("accept")
        .and_then(|v| {
            v.to_str()
                .map_err(|e| {
                    tracing::debug!(error = %e, "Invalid UTF-8 in Accept header");
                    e
                })
                .ok()
        })
        .is_some_and(|accept| {
            accept.contains("text/html") && !accept.starts_with("application/json")
        })
}