pub struct Config {
pub root: PathBuf,
pub trailing_slash: bool,
pub seo_inject: Option<SeoInject>,
pub api_prefixes: Option<Vec<String>>,
pub spa_fallback: bool,
pub not_found: Option<NotFoundHandler>,
pub disable_cache: bool,
pub html_cache_max_bytes: i64,
}Available on crate feature
nextstatic only.Expand description
托管配置; 用 Config::new 指定导出目录, 其余按需覆盖
Fields§
§root: PathBufNext.js export 产物目录 (out/), 必填
trailing_slash: bool与 next.config 的 trailingSlash: true 对齐; 开启后无扩展名页面请求先 308 补斜杠
seo_inject: Option<SeoInject>可选的 HTML 注入钩子, 写出任何 HTML 前调用 (含动态路由占位模板与 404 页)
api_prefixes: Option<Vec<String>>命中这些前缀的请求返回 JSON 404, 不落页面兜底; None 默认 ["/api/"], Some(vec![]) 关闭
spa_fallback: bool页面未命中时兜底根 index.html 并返回 200 (纯 SPA 形态); 默认返回 404.html + 404
not_found: Option<NotFoundHandler>自定义 404 处理器, 替代默认的 404.html 逻辑
disable_cache: bool关闭文件索引与 HTML 缓存, 每次请求读盘; 只用于本地开发
html_cache_max_bytes: i64HTML 内存缓存总量上限; 零默认 64MB, 负值关闭 HTML 缓存 (文件索引仍生效); 达到上限后新页面每次读盘
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Config
impl !UnwindSafe for Config
impl Forget for Config
impl Freeze for Configwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<dyn Fn(&Parts, Bytes) -> Bytes + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&Parts, Bytes) -> Bytes + Sync + Send>>: Freeze,
PhantomData<String>: Freeze,
*const ArcInner<dyn Fn(&Parts) -> Response<Bytes> + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&Parts) -> Response<Bytes> + Sync + Send>>: Freeze,
impl Move for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Configwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<dyn Fn(&Parts, Bytes) -> Bytes + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&Parts, Bytes) -> Bytes + Sync + Send>>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const ArcInner<dyn Fn(&Parts) -> Response<Bytes> + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&Parts) -> Response<Bytes> + Sync + Send>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more