huskies: merge 858
This commit is contained in:
@@ -34,6 +34,7 @@ pub struct PermissionForward {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
/// Shared application state threaded through all HTTP handlers via Poem's `Data` extractor.
|
||||
pub struct AppContext {
|
||||
pub state: Arc<SessionState>,
|
||||
pub store: Arc<JsonFileStore>,
|
||||
@@ -78,6 +79,7 @@ pub struct AppContext {
|
||||
|
||||
#[cfg(test)]
|
||||
impl AppContext {
|
||||
/// Build a minimal `AppContext` for unit tests with an in-memory store.
|
||||
pub fn new_test(project_root: std::path::PathBuf) -> Self {
|
||||
use crate::agents::AgentPool;
|
||||
let state = SessionState::default();
|
||||
@@ -119,12 +121,15 @@ impl AppContext {
|
||||
}
|
||||
}
|
||||
|
||||
/// Alias for `poem::Result<T>` used by OpenAPI handler return types.
|
||||
pub type OpenApiResult<T> = poem::Result<T>;
|
||||
|
||||
/// Return a 400 Bad Request error with the given message.
|
||||
pub fn bad_request(message: String) -> poem::Error {
|
||||
poem::Error::from_string(message, StatusCode::BAD_REQUEST)
|
||||
}
|
||||
|
||||
/// Return a 404 Not Found error with the given message.
|
||||
pub fn not_found(message: String) -> poem::Error {
|
||||
poem::Error::from_string(message, StatusCode::NOT_FOUND)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user