Skip to main content

BaseHandler

Struct BaseHandler 

Source
pub struct BaseHandler { /* private fields */ }
Expand description

Base HTTP request handler

Handles the complete request lifecycle including URL resolution, view execution, and signal emission.

Implementations§

Source§

impl BaseHandler

Source

pub fn new() -> Self

Create a new base handler

Source

pub fn with_router(router: Arc<DefaultRouter>) -> Self

Create a handler with a router

§Examples
use reinhardt_dispatch::BaseHandler;
use reinhardt_urls::routers::DefaultRouter;
use std::sync::Arc;

let router = DefaultRouter::new();
let handler = BaseHandler::with_router(Arc::new(router));
assert!(handler.is_async());
Source

pub async fn handle_request( &self, request: Request, ) -> Result<Response, DispatchError>

Handle an HTTP request

This is the main entry point for request processing. It:

  1. Emits request_started signal
  2. Resolves URL and dispatches to view
  3. Emits request_finished signal
Source

pub async fn handle_exception( &self, _request: &Request, error: DispatchError, ) -> Response

Process an exception and convert it to a response.

Error details are logged server-side but not included in the response body to prevent information disclosure.

Source

pub fn is_async(&self) -> bool

Check if handler is configured for async mode

Source

pub fn set_async(&mut self, is_async: bool)

Set async mode for the handler

Trait Implementations§

Source§

impl Default for BaseHandler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Handler for BaseHandler

Source§

fn handle<'life0, 'async_trait>( &'life0 self, request: Request, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles an HTTP request and produces a response. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more