use nova_core::response::ServerResponse;
use nova_core::types::request_type::RequestType;
use crate::callable::CloneableFn;
use crate::routes::Routes;
pub trait ServerRouting
where
Self: Clone,
{
#[must_use]
fn route<F: CloneableFn<Output = ServerResponse> + 'static>(
&mut self,
r#type: RequestType,
path: &str,
f: F,
) -> Self
where
Self: Sized;
#[must_use]
fn service(&mut self, path: &str, routes: Routes) -> Self
where
Self: Sized;
#[must_use]
fn fallback<F: CloneableFn<Output = ServerResponse> + 'static>(&mut self, f: F) -> Self
where
Self: Sized;
#[must_use]
fn get<F: CloneableFn<Output = ServerResponse> + 'static>(&mut self, path: &str, f: F) -> Self
where
Self: Sized,
{
self.route(RequestType::Get, path, f)
}
#[must_use]
fn post<F: CloneableFn<Output = ServerResponse> + 'static>(&mut self, path: &str, f: F) -> Self
where
Self: Sized,
{
self.route(RequestType::Post, path, f)
}
#[must_use]
fn put<F: CloneableFn<Output = ServerResponse> + 'static>(&mut self, path: &str, f: F) -> Self
where
Self: Sized,
{
self.route(RequestType::Put, path, f)
}
#[must_use]
fn patch<F: CloneableFn<Output = ServerResponse> + 'static>(&mut self, path: &str, f: F) -> Self
where
Self: Sized,
{
self.route(RequestType::Patch, path, f)
}
#[must_use]
fn delete<F: CloneableFn<Output = ServerResponse> + 'static>(
&mut self,
path: &str,
f: F,
) -> Self
where
Self: Sized,
{
self.route(RequestType::Delete, path, f)
}
}