Struct actix_web_lab::web::Spa
source · pub struct Spa { /* private fields */ }
Available on crate feature
spa
only.Expand description
Single Page App (SPA) service builder.
§Examples
App::new()
// ...api routes...
.service(
spa()
.index_file("./examples/assets/spa.html")
.static_resources_mount("/static")
.static_resources_location("./examples/assets")
.finish(),
)
Implementations§
source§impl Spa
impl Spa
sourcepub fn index_file(self, index_file: impl Into<Cow<'static, str>>) -> Self
pub fn index_file(self, index_file: impl Into<Cow<'static, str>>) -> Self
Location of the SPA index file.
This file will be served if:
- the Actix Web router has reached this service, indicating that none of the API routes matched the URL path;
- and none of the static resources handled matched.
The default is “./index.html”. I.e., the index.html
file located in the directory that
the server is running from.
sourcepub fn static_resources_mount(
self,
static_resources_mount: impl Into<Cow<'static, str>>,
) -> Self
pub fn static_resources_mount( self, static_resources_mount: impl Into<Cow<'static, str>>, ) -> Self
The URL path prefix that static files should be served from.
The default is “/”. I.e., static files are served from the root URL path.
sourcepub fn static_resources_location(
self,
static_resources_location: impl Into<Cow<'static, str>>,
) -> Self
pub fn static_resources_location( self, static_resources_location: impl Into<Cow<'static, str>>, ) -> Self
The location in the filesystem to serve static resources from.
The default is “./”. I.e., static files are located in the directory the server is running from.
sourcepub fn finish(self) -> impl HttpServiceFactory
pub fn finish(self) -> impl HttpServiceFactory
Constructs the service for use in a .service()
call.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Spa
impl RefUnwindSafe for Spa
impl Send for Spa
impl Sync for Spa
impl Unpin for Spa
impl UnwindSafe for Spa
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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