sa-token-plugin-rocket-core 0.1.18

Framework-agnostic core types for sa-token Rocket integration
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Shared JSON bodies for HTTP bindings (framework-agnostic core).

use sa_token_core::error::messages;
use serde_json::{json, Value};

pub fn unauthorized_body() -> Value {
    json!({ "code": 401, "message": messages::AUTH_ERROR })
}

pub fn forbidden_body(reason: &str) -> Value {
    json!({ "code": 403, "message": reason })
}

pub const CONTENT_TYPE_JSON: &str = "application/json";