use std::borrow::Cow;
use http::Method;
use crate::{Path, RouteFn, RouteHandlerFn};
#[doc(hidden)]
#[derive(Debug, Clone)]
pub struct ModuleRouteFn {
method: Method,
module_path: &'static str,
pub(super) render: RouteHandlerFn,
}
impl ModuleRouteFn {
pub const fn new(method: Method, module_path: &'static str, render: RouteHandlerFn) -> Self {
Self {
method,
module_path,
render,
}
}
#[must_use]
pub fn into_route(self, path: Cow<'static, Path>) -> RouteFn {
RouteFn::new(self.method, path, self.render)
}
#[must_use]
pub fn module_path(&self) -> &'static str {
self.module_path
}
}
#[cfg(feature = "discover")]
inventory::collect!(ModuleRouteFn);