pub enum Decision {
Allow,
Block {
status: u16,
body: Option<String>,
headers: Option<HashMap<String, String>>,
},
Redirect {
url: String,
status: u16,
},
Challenge {
challenge_type: String,
params: HashMap<String, String>,
},
}Expand description
Agent response decision indicating how to handle a request or response.
This enum represents the decision an agent makes when processing a request or response. It allows agents to allow, block, redirect, or challenge requests based on their processing logic.
§Variants
- Allow: Continue normal processing without modification
- Block: Reject the request/response with a custom error response
- Redirect: Send the client to a different URL
- Challenge: Request additional verification from the client
§Examples
use std::collections::HashMap;
use zentinel_agent_protocol::Decision;
// Allow request to proceed normally
let allow = Decision::Allow;
// Block with 403 and custom body
let block = Decision::Block {
status: 403,
body: Some("Access denied".to_string()),
headers: None,
};
// Redirect to login page
let redirect = Decision::Redirect {
url: "https://example.com/login".to_string(),
status: 302,
};
// Challenge with CAPTCHA
let mut params = HashMap::new();
params.insert("type".to_string(), "recaptcha".to_string());
let challenge = Decision::Challenge {
challenge_type: "captcha".to_string(),
params,
};Variants§
Allow
Allow the request/response to continue without modification.
This is the default decision that indicates normal processing should proceed.
Block
Block the request/response with a custom error response.
The proxy will return the specified status code and optional body/headers instead of forwarding the request to the upstream or returning the original response.
Fields
Redirect
Redirect the client to a different URL.
The proxy will return a redirect response with the specified URL and status code.
Fields
Challenge
Request additional verification from the client.
This can be used to implement CAPTCHA, multi-factor authentication, or other challenge-response mechanisms.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Decision
impl<'de> Deserialize<'de> for Decision
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Decision
impl StructuralPartialEq for Decision
Auto Trait Implementations§
impl Freeze for Decision
impl RefUnwindSafe for Decision
impl Send for Decision
impl Sync for Decision
impl Unpin for Decision
impl UnsafeUnpin for Decision
impl UnwindSafe for Decision
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request