pub struct App { /* private fields */ }Expand description
Fluent application builder — the Rust equivalent of Laravel 11+’s
bootstrap/app.php.
§Example
ⓘ
use larastvel_core::bootstrap::App;
use std::sync::Arc;
#[tokio::main]
async fn main() {
App::configure(None)
.with_routing(|r| {
routes::web::web(r);
})
.with_providers(|app| {
app.register_provider(Arc::new(
RouteServiceProvider::new()
.web(|r| routes::web::web(r)),
));
})
.with_console_commands(|kernel| {
kernel.add_command(Arc::new(MyCommand));
})
.run()
.await;
}Implementations§
Source§impl App
impl App
Sourcepub fn configure(base_path: Option<PathBuf>) -> Self
pub fn configure(base_path: Option<PathBuf>) -> Self
Create a new application builder with an optional base path.
Pass None to use the current directory as the base path.
Sourcepub fn with_routing(self, f: impl FnOnce(&Registrar) + Send + 'static) -> Self
pub fn with_routing(self, f: impl FnOnce(&Registrar) + Send + 'static) -> Self
Register web and/or API routes via a closure that receives a Registrar.
Multiple calls accumulate; each closure is called during boot.
Sourcepub fn with_providers(
self,
f: impl FnOnce(&Application) + Send + 'static,
) -> Self
pub fn with_providers( self, f: impl FnOnce(&Application) + Send + 'static, ) -> Self
Register service providers via a closure that receives the Application.
Sourcepub fn with_console_commands(
self,
f: impl FnOnce(&ConsoleKernel) + Send + 'static,
) -> Self
pub fn with_console_commands( self, f: impl FnOnce(&ConsoleKernel) + Send + 'static, ) -> Self
Register console commands via a closure that receives the ConsoleKernel.
Multiple calls accumulate; each closure is called during boot.
Sourcepub fn with_layer(
self,
f: impl FnOnce(AxumRouter) -> AxumRouter + Send + 'static,
) -> Self
pub fn with_layer( self, f: impl FnOnce(AxumRouter) -> AxumRouter + Send + 'static, ) -> Self
Add a Tower layer or Axum extension to the final application router.
The closure receives the fully-built Router after all routes are
registered and must return a router. Multiple calls accumulate.
ⓘ
use larastvel_core::axum::Extension;
App::configure(None)
.with_routing(|r| { /* routes */ })
.with_layer(|router| router.layer(Extension(my_state)))
.run()
.await;Auto Trait Implementations§
impl !RefUnwindSafe for App
impl !Sync for App
impl !UnwindSafe for App
impl Freeze for App
impl Send for App
impl Unpin for App
impl UnsafeUnpin for App
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more