Struct leptos_config::LeptosOptions
source · pub struct LeptosOptions {
pub output_name: String,
pub site_root: String,
pub site_pkg_dir: String,
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: String,
pub hash_file: String,
pub hash_files: 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§
§output_name: String
The name of the WASM and JS files generated by wasm-bindgen. Defaults to the crate name with underscores instead of dashes
site_root: String
The path of the all the files generated by cargo-leptos. This defaults to ‘.’ for convenience when integrating with other tools.
site_pkg_dir: String
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: Env
Used 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: SocketAddr
Provides 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: u32
The 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: ReloadWSProtocol
The 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: String
The path of a custom 404 Not Found page to display when statically serving content, defaults to site_root/404.html
hash_file: String
The file name of the hash text file generated by cargo-leptos. Defaults to hash.txt
.
hash_files: bool
If true, hashes will be generated for all files in the site_root and added to their file names.
Defaults to true
.
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(...)
(optional), .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) 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 more