Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ Update failing tests #295

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mod config;
pub mod config;
mod errors;
mod filter;
mod http_server;
mod middleware;
pub mod middleware;
mod routers;
mod utils;

Expand Down
19 changes: 15 additions & 4 deletions apps/server/src/middleware/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,22 @@ async fn handle_basic_auth(
/// ## Example:
///
/// ```rust
/// use axum::{Router, middleware::from_extractor};
/// use axum::{Router, middleware::{from_extractor, from_extractor_with_state}};
/// use stump_core::{Ctx, config::StumpConfig};
/// use stump_server::{
/// middleware::auth::{Auth, ServerOwnerGuard},
/// config::state::AppState
/// };
///
/// Router::new()
/// .layer(from_extractor::<ServerOwnerGuard>())
/// .layer(from_extractor_with_state::<Auth, AppState>(app_state));
/// #[tokio::main]
/// async fn main() {
/// let config = StumpConfig::debug();
/// let ctx = Ctx::new(config).await.arced();
///
/// let router: Router<AppState> = Router::new()
/// .layer(from_extractor::<ServerOwnerGuard>())
/// .layer(from_extractor_with_state::<Auth, AppState>(ctx));
/// }
/// ```
pub struct ServerOwnerGuard;

Expand Down
22 changes: 9 additions & 13 deletions core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,13 @@ impl Ctx {
/// ## Example
/// ```rust
/// use stump_core::{Ctx, config::StumpConfig};
/// use tokio::sync::mpsc::unbounded_channel;
/// use std::sync::Arc;
///
/// #[tokio::main]
/// async fn main() {
/// let (sender, _) = unbounded_channel();
/// let config = StumpConfig::debug();
///
/// let ctx = Ctx::new(config, sender).await;
/// let ctx = Ctx::new(config).await;
/// let arced_ctx = ctx.arced();
/// let ctx_clone = arced_ctx.clone();
///
Expand All @@ -118,18 +116,16 @@ impl Ctx {
///
/// ## Example
/// ```rust
/// use stump_core::{Ctx, config::StumpConfig, event::CoreEvent};
/// use tokio::sync::mpsc::unbounded_channel;
/// use stump_core::{Ctx, config::StumpConfig, CoreEvent};
///
/// #[tokio::main]
/// async fn main() {
/// let (sender, _) = unbounded_channel();
/// let config = StumpConfig::debug();
/// let ctx = Ctx::new(config, sender).await;
/// let ctx = Ctx::new(config).await;
///
/// let event = CoreEvent::JobFailed {
/// job_id: "Gandalf quote".to_string(),
/// message: "When in doubt, follow your nose".to_string(),
/// let event = CoreEvent::CreatedMedia {
/// id: "id_for_the_media".to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a LOTR fan? 😉

/// series_id: "id_for_its_series".to_string(),
/// };
///
/// let ctx_cpy = ctx.clone();
Expand All @@ -138,9 +134,9 @@ impl Ctx {
/// let received_event = receiver.recv().await;
/// assert_eq!(received_event.is_ok(), true);
/// match received_event.unwrap() {
/// CoreEvent::JobFailed { job_id, message } => {
/// assert_eq!(job_id, "Gandalf quote");
/// assert_eq!(message, "When in doubt, follow your nose");
/// CoreEvent::CreatedMedia { id, series_id } => {
/// assert_eq!(id, "id_for_the_media");
/// assert_eq!(series_id, "id_for_its_series");
/// }
/// _ => unreachable!("Wrong event type received"),
/// }
Expand Down
Loading