fraiseql-server 2.3.0

HTTP server for FraiseQL v2 GraphQL engine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Path parameter type coercion.

use serde_json::json;

/// Coerce a path parameter string to an appropriate JSON value.
///
/// Attempts integer, then boolean, then falls back to string.
pub(super) fn coerce_path_param_value(value: &str) -> serde_json::Value {
    if let Ok(n) = value.parse::<i64>() {
        return json!(n);
    }
    match value {
        "true" => return json!(true),
        "false" => return json!(false),
        _ => {},
    }
    json!(value)
}