#[non_exhaustive]pub struct LeptosOptions {Show 14 fields
pub output_name: Arc<str>,
pub site_root: Arc<str>,
pub site_pkg_dir: Arc<str>,
pub env: Env,
pub site_addr: SocketAddr,
pub reload_port: u32,
pub reload_external_port: Option<u32>,
pub reload_ws_protocol: ReloadWSProtocol,
pub not_found_path: Arc<str>,
pub hash_file: Arc<str>,
pub hash_files: bool,
pub server_fn_prefix: Option<String>,
pub disable_server_fn_hash: bool,
pub server_fn_mod_path: bool,
}Expand description
This struct serves as a convenient place to store details used for configuring Leptos. It’s used in our actix and axum integrations to generate the correct path for WASM, JS, and Websockets, as well as other configuration tasks. It shares keys with cargo-leptos, to allow for easy interoperability
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.output_name: Arc<str>The name of the WASM and JS files generated by wasm-bindgen.
This should match the name that will be output when building your application.
You can easily set this using env!("CARGO_CRATE_NAME").
site_root: Arc<str>The path of the all the files generated by cargo-leptos. This defaults to ‘.’ for convenience when integrating with other tools.
site_pkg_dir: Arc<str>The path of the WASM and JS files generated by wasm-bindgen from the root of your app
By default, wasm-bindgen puts them in pkg.
env: EnvUsed to configure the running environment of Leptos. Can be used to load dev constants and keys v prod, or change
things based on the deployment environment
I recommend passing in the result of env::var("LEPTOS_ENV")
site_addr: SocketAddrProvides a way to control the address leptos is served from.
Using an env variable here would allow you to run the same code in dev and prod
Defaults to 127.0.0.1:3000
reload_port: u32The port the Websocket watcher listens on. Should match the reload_port in cargo-leptos(if using).
Defaults to 3001
reload_external_port: Option<u32>The port the Websocket watcher listens on when on the client, e.g., when behind a reverse proxy. Defaults to match reload_port
reload_ws_protocol: ReloadWSProtocolThe protocol the Websocket watcher uses on the client: ws in most cases, wss when behind a reverse https proxy.
Defaults to ws
not_found_path: Arc<str>The path of a custom 404 Not Found page to display when statically serving content, defaults to site_root/404.html
hash_file: Arc<str>The file name of the hash text file generated by cargo-leptos. Defaults to hash.txt.
hash_files: boolIf true, hashes will be generated for all files in the site_root and added to their file names.
Defaults to false.
server_fn_prefix: Option<String>The default prefix to use for server functions when generating API routes. Can be
overridden for individual functions using #[server(prefix = "...")] as usual.
This is useful to override the default prefix (/api) for all server functions without
needing to manually specify via #[server(prefix = "...")] on every server function.
disable_server_fn_hash: boolWhether to disable appending the server functions’ hashes to the end of their API names.
This is useful when an app’s client side needs a stable server API. For example, shipping the CSR WASM binary in a Tauri app. Tauri app releases are dependent on each platform’s distribution method (e.g., the Apple App Store or the Google Play Store), which typically are much slower than the frequency at which a website can be updated. In addition, it’s common for users to not have the latest app version installed. In these cases, the CSR WASM app would need to be able to continue calling the backend server function API, so the API path needs to be consistent and not have a hash appended.
Note that the hash suffixes is intended as a way to ensure duplicate API routes are created. Without the hash, server functions will need to have unique names to avoid creating duplicate routes. Axum will throw an error if a duplicate route is added to the router, but Actix will not.
server_fn_mod_path: boolInclude the module path of the server function in the API route. This is an alternative
strategy to prevent duplicate server function API routes (the default strategy is to add
a hash to the end of the route). Each element of the module path will be separated by a /.
For example, a server function with a fully qualified name of parent::child::server_fn
would have an API route of /api/parent/child/server_fn (possibly with a
different prefix and a hash suffix depending on the values of the other server fn configs).
Implementations§
Source§impl LeptosOptions
impl LeptosOptions
Sourcepub fn builder() -> LeptosOptionsBuilder
pub fn builder() -> LeptosOptionsBuilder
Create a builder for building LeptosOptions.
On the builder, call .output_name(...), .site_root(...)(optional), .site_pkg_dir(...)(optional), .env(...)(optional), .site_addr(...)(optional), .reload_port(...)(optional), .reload_external_port(...)(optional), .reload_ws_protocol(...)(optional), .not_found_path(...)(optional), .hash_file(...)(optional), .hash_files(...)(optional), .server_fn_prefix(...)(optional), .disable_server_fn_hash(...)(optional), .server_fn_mod_path(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of LeptosOptions.
Trait Implementations§
Source§impl Clone for LeptosOptions
impl Clone for LeptosOptions
Source§fn clone(&self) -> LeptosOptions
fn clone(&self) -> LeptosOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LeptosOptions
impl Debug for LeptosOptions
Source§impl<'de> Deserialize<'de> for LeptosOptions
impl<'de> Deserialize<'de> for LeptosOptions
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LeptosOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LeptosOptions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for LeptosOptions
impl RefUnwindSafe for LeptosOptions
impl Send for LeptosOptions
impl Sync for LeptosOptions
impl Unpin for LeptosOptions
impl UnwindSafe for LeptosOptions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromFormData for Twhere
T: DeserializeOwned,
impl<T> FromFormData for Twhere
T: DeserializeOwned,
Source§fn from_event(ev: &Event) -> Result<T, FromFormDataError>
fn from_event(ev: &Event) -> Result<T, FromFormDataError>
submit event.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>
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>
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