Struct saphir::controller::EndpointsBuilder
source · pub struct EndpointsBuilder<C: Controller> { /* private fields */ }
Expand description
Builder to simplify returning a list of endpoints in the handlers
method
of the controller trait
Implementations§
source§impl<C: Controller> EndpointsBuilder<C>
impl<C: Controller> EndpointsBuilder<C>
sourcepub fn add<H>(self, method: Method, route: &'static str, handler: H) -> Selfwhere
H: 'static + DynControllerHandler<C, Body> + Send + Sync,
pub fn add<H>(self, method: Method, route: &'static str, handler: H) -> Selfwhere H: 'static + DynControllerHandler<C, Body> + Send + Sync,
Add a endpoint the the builder
impl BasicController {
async fn healthz(&self, req: Request<Body>) -> impl Responder {200}
}
let b: EndpointsBuilder<BasicController> = EndpointsBuilder::new().add(Method::GET, "/healthz", BasicController::healthz);
sourcepub fn add_with_guards<H, F, Chain>(
self,
method: Method,
route: &'static str,
handler: H,
guards: F
) -> Selfwhere
H: 'static + DynControllerHandler<C, Body> + Send + Sync,
F: FnOnce(GuardBuilder<GuardChainEnd>) -> GuardBuilder<Chain>,
Chain: GuardChain + 'static,
pub fn add_with_guards<H, F, Chain>( self, method: Method, route: &'static str, handler: H, guards: F ) -> Selfwhere H: 'static + DynControllerHandler<C, Body> + Send + Sync, F: FnOnce(GuardBuilder<GuardChainEnd>) -> GuardBuilder<Chain>, Chain: GuardChain + 'static,
Add a guarded endpoint the the builder
sourcepub fn add_with_name<H>(
self,
handler_name: &'static str,
method: Method,
route: &'static str,
handler: H
) -> Selfwhere
H: 'static + DynControllerHandler<C, Body> + Send + Sync,
pub fn add_with_name<H>( self, handler_name: &'static str, method: Method, route: &'static str, handler: H ) -> Selfwhere H: 'static + DynControllerHandler<C, Body> + Send + Sync,
Add but with a handler name
sourcepub fn add_with_guards_and_name<H, F, Chain>(
self,
handler_name: &'static str,
method: Method,
route: &'static str,
handler: H,
guards: F
) -> Selfwhere
H: 'static + DynControllerHandler<C, Body> + Send + Sync,
F: FnOnce(GuardBuilder<GuardChainEnd>) -> GuardBuilder<Chain>,
Chain: GuardChain + 'static,
pub fn add_with_guards_and_name<H, F, Chain>( self, handler_name: &'static str, method: Method, route: &'static str, handler: H, guards: F ) -> Selfwhere H: 'static + DynControllerHandler<C, Body> + Send + Sync, F: FnOnce(GuardBuilder<GuardChainEnd>) -> GuardBuilder<Chain>, Chain: GuardChain + 'static,
Add with guard but with a handler name
sourcepub fn build(self) -> Vec<ControllerEndpoint<C>>
pub fn build(self) -> Vec<ControllerEndpoint<C>>
Finish the builder into a Vec<ControllerEndpoint<C>>
Trait Implementations§
source§impl<C: Default + Controller> Default for EndpointsBuilder<C>
impl<C: Default + Controller> Default for EndpointsBuilder<C>
source§fn default() -> EndpointsBuilder<C>
fn default() -> EndpointsBuilder<C>
Returns the “default value” for a type. Read more