Skip to main content

Crate next_rust_server

Crate next_rust_server 

Source
Expand description

The Next Rust runtime.

Most applications use this crate through the next-rust facade. It contains the request pipeline (middleware → routing → pages/API routes/ server actions), server-side rendering with streaming, incremental static regeneration, static files, the development endpoints and the hyper-based production server.

Re-exports§

pub use actions::ActionContext;
pub use actions::ActionRef;
pub use app::ActionDef;
pub use app::ApiDef;
pub use app::App;
pub use app::AppBuilder;
pub use app::ErrorInfo;
pub use app::PageBody;
pub use app::PageDef;
pub use app::Rendering;
pub use app::Routes;
pub use app::SegmentDef;
pub use app::SlotDef;
pub use app::parse_pattern;
pub use context::Auth;
pub use context::AuthUser;
pub use context::ClientIp;
pub use context::CsrfToken;
pub use context::Ctx;
pub use context::Data;
pub use context::Extension;
pub use context::FormState;
pub use context::FromContext;
pub use context::Headers;
pub use context::Nonce;
pub use context::Path;
pub use context::Query;
pub use context::QueryMap;
pub use context::RenderMode;
pub use context::RequestContext;
pub use context::RequestInfo;
pub use context::ResponseHeaders;
pub use cookies::Cookie;
pub use cookies::Cookies;
pub use cookies::SameSite;
pub use embed::Embedded;
pub use embed::EmbeddedFile;
pub use error::Error;
pub use error::ErrorKind;
pub use error::OrNotFound;
pub use error::Result;
pub use error::not_found;
pub use error::permanent_redirect;
pub use error::redirect;
pub use middleware::BoxFuture;
pub use middleware::Cors;
pub use middleware::Middleware;
pub use middleware::Next;
pub use middleware::RateLimit;
pub use middleware::RequestId;
pub use middleware::cors;
pub use middleware::csrf;
pub use middleware::protected;
pub use middleware::rate_limit;
pub use middleware::request_id;
pub use middleware::security_headers;
pub use request::Request;
pub use response::Body;
pub use response::Html;
pub use response::IntoResponse;
pub use response::Json;
pub use response::Response;
pub use runtime::run;
pub use runtime::run_with;
pub use seo::Feed;
pub use seo::FeedEntry;
pub use seo::Robots;
pub use seo::RobotsRule;
pub use seo::Sitemap;
pub use seo::SitemapEntry;
pub use session::MemorySessionStore;
pub use session::Session;
pub use session::SessionStore;
pub use session::sessions;
pub use sse::SseEvent;
pub use testing::TestClient;
pub use testing::TestResponse;
pub use middleware::STRICT_CSP;
pub use bytes;
pub use futures_util as futures;
pub use http;
pub use tokio;

Modules§

actions
Server actions: #[server_action] functions exposed at POST /_next-rust/action/<token>.
app
Route definitions, application builder and request dispatch.
context
Render context and extractors.
cookies
Cookies with secure defaults.
embed
Files compiled into the production binary.
error
The error type used by pages, layouts, loaders, API routes and actions.
export
Static generation: renders static routes into a page cache.
http_date
IMF-fixdate formatting (RFC 9110 §5.6.7) without external dependencies.
jobs
Background and scheduled jobs.
log
Minimal structured logging.
middleware
Middleware.
plugin
Runtime plugins.
request
Incoming HTTP request.
response
Outgoing HTTP response.
runtime
Process entry point used by next_rust::main!().
seo
Generated sitemap.xml and robots.txt (app/sitemap.rs, app/robots.rs).
server
Production HTTP server built on hyper.
session
Server-side sessions.
sse
Server-Sent Events.
static_files
Static file serving for public/ (and framework client files), from disk in development and from the binary in release builds.
testing
In-process testing without a network socket.

Structs§

CspNonce
Per-request CSP nonce stored in request extensions.

Constants§

CSRF_COOKIE
Name of the CSRF double-submit cookie.
SECRET_ENV
Environment variable holding the server secret.
VERSION
The framework’s version, as in Cargo.toml.

Functions§

constant_time_eq
Constant-time byte comparison (for tokens).
is_dev
Whether the process runs in development mode (detailed errors).
random_hex
n random bytes from the operating system CSPRNG, hex encoded.
revalidate_path
Re-render path on its next request (pages rendered statically) and drop the matching data-cache entry. Usable from API routes and actions.
revalidate_tag
Invalidate every cached page and data entry tagged with tag.
signature
The build signature (Next Rust 0.1.10): what a page’s <meta name="generator"> and the framework’s scripts say built them while [build] signature = true.