1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use clap::Args;
use crate::commons::models::CommonOpts;
use crate::commons::parse_key_val;
#[derive(Args, Clone, Debug)]
pub struct ServeOpts {
#[clap(flatten)]
pub inner: ServeOptsInner,
#[clap(flatten)]
pub common: CommonOpts,
}
#[derive(Args, Clone, Debug)]
pub struct ServeOptsInner {
#[arg(long, default_value_t = {"127.0.0.1".into()})]
pub host: String,
#[arg(long, default_value_t = {4444})]
pub port: u16,
/// sets up proxy: `--proxy /path=http://domain.com/path`
///
/// Websockets under the path go through as well.
#[arg(long, value_parser = parse_key_val::<String, String>)]
pub proxy: Vec<(String, String)>,
/// Define a mount point for the app in public url.
///
/// (For example an nginx's location in which proxy_pass to the app was defined)
#[arg(long, default_value_t = {"/".to_string()})]
pub mount_point: String,
/// Setting the parameters `--env api=http://domain.com/api --env api2=http://domain.com/api2`
#[arg(long, value_parser = parse_key_val::<String, String>)]
pub env: Vec<(String, String)>,
/// Whether to start downloading and compiling WASM while the page loads, instead of after
/// (at low priority, so images and styles take precedence)
#[arg(long, default_value_t = {false})]
pub wasm_preload: bool,
/// Disable hydration on page load (will re-create DOM instead of claiming existing nodes from SSR)
#[arg(long, default_value_t = {false})]
pub disable_hydration: bool,
/// Origin for resolving relative fetch URLs during SSR: `--ssr-fetch-base http://127.0.0.1:8080`
///
/// (default: this server's address)
#[arg(long)]
pub ssr_fetch_base: Option<String>,
/// A cookie the app may read during SSR too, f. ex. the language the user picked:
/// `--ssr-cookie lang --ssr-cookie theme`
///
/// (only one the browser shows the app too, not `HttpOnly`: the server would render what the
/// browser can't)
#[arg(long)]
pub ssr_cookie: Vec<String>,
/// A cookie that goes out with the SSR fetches to this server's own origin, f. ex. the session:
/// `--ssr-fetch-cookie session`
///
/// (default: all of them. Once one is named the others stay behind, and a visitor with only
/// those is rendered as a guest, which a cache on the way may keep)
#[arg(long)]
pub ssr_fetch_cookie: Vec<String>,
/// Indent the server-rendered HTML, to read it in the page source
///
/// (the indentation is whitespace between elements: until the app starts, it shows as gaps
/// between inline ones, which hydration then takes out)
#[arg(long, default_value_t = {false})]
pub pretty_html: bool,
/// Disable gzip/brotli/zstd compression of served responses
///
/// (useful behind a proxy or CDN that already compresses)
#[arg(long, default_value_t = {false})]
pub disable_compression: bool,
/// Compress the wasm, `wasm_run.js` and other text files of the build with brotli at its
/// highest level once, at startup, for the browsers that accept brotli
///
/// (about a quarter smaller than compressing each response, for about a second of startup
/// per megabyte)
#[arg(long, default_value_t = {false})]
pub precompress: bool,
/// Number of threads to use for processing requests
///
/// (default: number of CPU cores, 2 for watch mode)
#[arg(long)]
pub threads: Option<usize>,
}