vertigo_cli/serve/serve_opts.rs
1use clap::Args;
2
3use crate::commons::models::CommonOpts;
4use crate::commons::parse_key_val;
5
6#[derive(Args, Clone, Debug)]
7pub struct ServeOpts {
8 #[clap(flatten)]
9 pub inner: ServeOptsInner,
10 #[clap(flatten)]
11 pub common: CommonOpts,
12}
13
14#[derive(Args, Clone, Debug)]
15pub struct ServeOptsInner {
16 #[arg(long, default_value_t = {"127.0.0.1".into()})]
17 pub host: String,
18 #[arg(long, default_value_t = {4444})]
19 pub port: u16,
20
21 /// sets up proxy: `--proxy /path=http://domain.com/path`
22 ///
23 /// Websockets under the path go through as well.
24 #[arg(long, value_parser = parse_key_val::<String, String>)]
25 pub proxy: Vec<(String, String)>,
26
27 /// Define a mount point for the app in public url.
28 ///
29 /// (For example an nginx's location in which proxy_pass to the app was defined)
30 #[arg(long, default_value_t = {"/".to_string()})]
31 pub mount_point: String,
32
33 /// Setting the parameters `--env api=http://domain.com/api --env api2=http://domain.com/api2`
34 #[arg(long, value_parser = parse_key_val::<String, String>)]
35 pub env: Vec<(String, String)>,
36
37 /// Whether to add `<link rel="preload">` tag to `<head>` to make the browser load WASM earlier
38 #[arg(long, default_value_t = {false})]
39 pub wasm_preload: bool,
40
41 /// Disable hydration on page load (will re-create DOM instead of claiming existing nodes from SSR)
42 #[arg(long, default_value_t = {false})]
43 pub disable_hydration: bool,
44
45 /// Origin for resolving relative fetch URLs during SSR: `--ssr-fetch-base http://127.0.0.1:8080`
46 ///
47 /// (default: this server's address)
48 #[arg(long)]
49 pub ssr_fetch_base: Option<String>,
50
51 /// A cookie the app may read during SSR too, f. ex. the language the user picked:
52 /// `--ssr-cookie lang --ssr-cookie theme`
53 ///
54 /// (only one the browser shows the app too, not `HttpOnly`: the server would render what the
55 /// browser can't)
56 #[arg(long)]
57 pub ssr_cookie: Vec<String>,
58
59 /// Indent the server-rendered HTML, to read it in the page source
60 ///
61 /// (the indentation is whitespace between elements: until the app starts, it shows as gaps
62 /// between inline ones, which hydration then takes out)
63 #[arg(long, default_value_t = {false})]
64 pub pretty_html: bool,
65
66 /// Disable gzip/brotli/zstd compression of served responses
67 ///
68 /// (useful behind a proxy or CDN that already compresses)
69 #[arg(long, default_value_t = {false})]
70 pub disable_compression: bool,
71
72 /// Number of threads to use for processing requests
73 ///
74 /// (default: number of CPU cores, 2 for watch mode)
75 #[arg(long)]
76 pub threads: Option<usize>,
77}