autoendpoint/routers/stub/
settings.rs

1/// Settings for `StubRouter`
2/// These can be specified externally by the calling "client" during
3/// registration and contain values that will be echoed back.
4/// The `server_credentials` block is a JSON structure that contains
5/// the default response for any routing request. This defaults to
6/// 'error'.
7#[derive(Clone, Debug, serde::Deserialize)]
8#[serde(default)]
9#[serde(deny_unknown_fields)]
10pub struct StubSettings {
11    pub url: String,
12    #[serde(rename = "credentials")]
13    pub server_credentials: String,
14}
15
16/// `StubServerSettings` allows the server configuration file to specify
17/// the default error to use for requests to the "error" `app_id`.
18/// Requests to endpoints associated with this client will return the
19/// `error` string.
20#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
21pub struct StubServerSettings {
22    #[serde(default)]
23    pub error: String,
24}
25
26impl Default for StubServerSettings {
27    fn default() -> Self {
28        Self {
29            error: "General Error".to_owned(),
30        }
31    }
32}
33
34/// The `StubSettings` contains client provided data that can override
35/// the response error string when endpoints associated with this client
36/// are called.
37impl Default for StubSettings {
38    fn default() -> Self {
39        Self {
40            url: "http://localhost:8080".to_owned(),
41            server_credentials: "{\"error\":\"General Error\"}".to_owned(),
42        }
43    }
44}