next_rust_server/plugin.rs
1//! Runtime plugins.
2//!
3//! Build-time plugins (route scanning, code generation, asset processing)
4//! live in `next-rust-build`; runtime plugins can contribute middleware,
5//! document head markup and startup hooks.
6
7use std::sync::Arc;
8
9use next_rust_core::Config;
10
11use crate::middleware::Middleware;
12
13pub trait Plugin: Send + Sync + 'static {
14 /// Unique name, used in logs and for `[plugins.<name>]` configuration.
15 fn name(&self) -> &str;
16
17 /// Called once when the application is built.
18 fn on_start(&self, _config: &Config) {}
19
20 /// Middleware added after the application's global middleware.
21 fn middleware(&self) -> Vec<Arc<dyn Middleware>> {
22 Vec::new()
23 }
24
25 /// Trusted markup appended to every document `<head>`.
26 fn head(&self) -> Option<String> {
27 None
28 }
29}