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§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