murgamu 0.7.3

Murgamü is an NestJS-inspired web framework for Rust
Documentation
use crate::core::error::MurError;
use crate::mur_http::request::MurRequestContext;
use crate::types::MurRes;
use std::future::Future;
use std::pin::Pin;

pub trait MurInterceptor: Send + Sync + 'static {
	fn before(&self, _ctx: &MurRequestContext) -> MurInterceptorFuture {
		Box::pin(async { Ok(()) })
	}

	fn after(
		&self,
		_ctx: &MurRequestContext,
		response: MurRes,
	) -> Pin<Box<dyn Future<Output = MurRes> + Send>> {
		Box::pin(async move { response })
	}

	fn name(&self) -> &str {
		std::any::type_name::<Self>()
	}
}

pub type MurInterceptorFuture = Pin<Box<dyn Future<Output = Result<(), MurError>> + Send>>;