use super::into_middleware::IntoMiddleware;
use super::pending_resource_registrar::PendingResourceRegistration;
use super::pending_route_registrar::PendingRouteRegistrar;
use crate::contracts::support::Responsable;
use crate::http::{Controller, Method, Request};
use std::future::Future;
pub trait RouteRegistrar {
fn get<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn post<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn put<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn patch<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn delete<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn head<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn options<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn trace<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn connect<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn any<F, Fut, R>(&mut self, path: &str, handler: F) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn r#match<F, Fut, R>(
&mut self,
methods: &[Method],
path: &str,
handler: F,
) -> PendingRouteRegistrar<'_>
where
F: Fn(Request) -> Fut + Send + Sync + 'static,
Fut: Future<Output = R> + Send + 'static,
R: Responsable;
fn domain(&mut self, domain: impl Into<String>) -> PendingRouteRegistrar<'_>;
fn prefix(&mut self, prefix: impl Into<String>) -> PendingRouteRegistrar<'_>;
fn name(&mut self, name: impl Into<String>) -> PendingRouteRegistrar<'_>;
fn middleware(&mut self, middleware: impl IntoMiddleware) -> PendingRouteRegistrar<'_>;
fn without_middleware(&mut self, middleware: impl IntoMiddleware) -> PendingRouteRegistrar<'_>;
fn resource<C: Controller + 'static>(
&mut self,
name: &str,
controller: C,
) -> PendingResourceRegistration<'_>;
fn api_resource<C: Controller + 'static>(
&mut self,
name: &str,
controller: C,
) -> PendingResourceRegistration<'_> {
self.resource(name, controller).except(&["create", "edit"])
}
}