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