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