pub struct PluginBuilder<'r, D> { /* private fields */ }Expand description
What Plugin::init (and Builder::configure) registers things with.
Implementations§
Source§impl<D: Adapter> PluginBuilder<'_, D>
impl<D: Adapter> PluginBuilder<'_, D>
Sourcepub fn owner(&self) -> &'static str
pub fn owner(&self) -> &'static str
Id of the plugin being initialised ("app" for Builder::configure).
Sourcepub fn schema(&mut self) -> &mut SchemaBuilder
pub fn schema(&mut self) -> &mut SchemaBuilder
Adds tables or columns (normally done in Plugin::schema).
pub fn endpoint<E: Endpoint<D>>(&mut self, endpoint: E) -> &mut Self
Sourcepub fn server_endpoint<E: Endpoint<D>>(&mut self) -> &mut Self
pub fn server_endpoint<E: Endpoint<D>>(&mut self) -> &mut Self
Declares an endpoint with no HTTP route, one only the server API calls through
auth.api().call(..), so hooks may target it like a routed one.
Sourcepub fn hook<E: Endpoint<D>>(&mut self) -> HookBuilder<'_, D, E>
pub fn hook<E: Endpoint<D>>(&mut self) -> HookBuilder<'_, D, E>
Hooks around endpoint E, for every caller: app.hook::<SignUpEmail>().before(..).
Sourcepub fn sign_in_gate<F, Fut>(&mut self, gate: F) -> &mut Self
pub fn sign_in_gate<F, Fut>(&mut self, gate: F) -> &mut Self
Runs after credentials check out and before a session exists, for every sign-in method.
Gates run in registration order. The gate belongs to owner: when it
answers Gate::Challenge, this plugin finishes the sign-in with
Internal::complete_sign_in and its own id.
Sourcepub fn session_resolver(
&mut self,
resolver: impl SessionResolver<D>,
) -> &mut Self
pub fn session_resolver( &mut self, resolver: impl SessionResolver<D>, ) -> &mut Self
Turns non-cookie credentials (bearer tokens, API keys) into a session.
Sourcepub fn on_response(
&mut self,
hook: impl Fn(&Ctx<D>, &mut Response) + Send + Sync + 'static,
) -> &mut Self
pub fn on_response( &mut self, hook: impl Fn(&Ctx<D>, &mut Response) + Send + Sync + 'static, ) -> &mut Self
Runs on the HTTP response of every routed endpoint, after its cookies and headers are
set, in registration order. For headers derived from the response itself, like a
bearer plugin copying the session cookie into set-auth-token. Server API calls
don’t run it.
Sourcepub fn on<Ev, F, Fut>(&mut self, handler: F) -> &mut Self
pub fn on<Ev, F, Fut>(&mut self, handler: F) -> &mut Self
Runs after any endpoint that emitted Ev succeeds. Errors are logged, not returned.
Sourcepub fn rate_limit(
&mut self,
pattern: impl Into<String>,
limit: Limit,
) -> &mut Self
pub fn rate_limit( &mut self, pattern: impl Into<String>, limit: Limit, ) -> &mut Self
A rate-limit rule for a path pattern (/two-factor/*). App rules win over plugin rules.
Sourcepub fn errors<E: ErrorCodes>(&mut self) -> &mut Self
pub fn errors<E: ErrorCodes>(&mut self) -> &mut Self
Registers error codes so two plugins can’t claim the same one.