pub struct ScriptMiddleware { /* private fields */ }Expand description
A script-based middleware.
Can modify requests before handlers and responses after handlers.
Implementations§
Source§impl ScriptMiddleware
impl ScriptMiddleware
Sourcepub fn before(engine: Arc<RhaiEngine>, script_path: impl Into<PathBuf>) -> Self
pub fn before(engine: Arc<RhaiEngine>, script_path: impl Into<PathBuf>) -> Self
Create a new middleware with before script.
Sourcepub fn after(engine: Arc<RhaiEngine>, script_path: impl Into<PathBuf>) -> Self
pub fn after(engine: Arc<RhaiEngine>, script_path: impl Into<PathBuf>) -> Self
Create a new middleware with after script.
Sourcepub fn both(
engine: Arc<RhaiEngine>,
before: impl Into<PathBuf>,
after: impl Into<PathBuf>,
) -> Self
pub fn both( engine: Arc<RhaiEngine>, before: impl Into<PathBuf>, after: impl Into<PathBuf>, ) -> Self
Create a new middleware with both before and after scripts.
Sourcepub async fn call_before(
&self,
request: &HttpRequest,
) -> Result<Option<HttpResponse>>
pub async fn call_before( &self, request: &HttpRequest, ) -> Result<Option<HttpResponse>>
Execute the before script.
Returns Some(response) if the middleware wants to short-circuit,
or None to continue to the handler.
Sourcepub async fn call_after(
&self,
request: &HttpRequest,
response: HttpResponse,
) -> Result<HttpResponse>
pub async fn call_after( &self, request: &HttpRequest, response: HttpResponse, ) -> Result<HttpResponse>
Execute the after script.
Auto Trait Implementations§
impl Freeze for ScriptMiddleware
impl !RefUnwindSafe for ScriptMiddleware
impl Send for ScriptMiddleware
impl Sync for ScriptMiddleware
impl Unpin for ScriptMiddleware
impl !UnwindSafe for ScriptMiddleware
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
Mutably borrows from an owned value. Read more
Source§impl<T> Injectable for T
impl<T> Injectable for T
Source§fn type_id_of() -> TypeIdwhere
Self: Sized,
fn type_id_of() -> TypeIdwhere
Self: Sized,
Returns the TypeId of this type (for internal use)
Source§fn type_name_of() -> &'static strwhere
Self: Sized,
fn type_name_of() -> &'static strwhere
Self: Sized,
Returns the type name for debugging