|
5 | 5 | You must have Rust installed to build `ambi_mock_client`. |
6 | 6 | You can find documentation on installing Rust [here](https://www.rust-lang.org/tools/install). |
7 | 7 |
|
| 8 | +You will also need a local copy of [Ambi](https://github.com/jhodapp/ambi) running ( default port 4000 ). |
| 9 | + |
8 | 10 | ### Using cargo run |
9 | | -```Rust |
| 11 | +```BASH |
10 | 12 | > cargo build |
11 | 13 | > cargo run |
12 | | -{"tempurature":"23.7","humidity":"63.8","pressure":"945","dust_concentration":"999","air_purity":"DANGEROUS"} |
| 14 | + |
| 15 | +Sending POST request to http://localhost:4000/api/readings/add as JSON: {"tempurature":"19.2","humidity":"87.7","pressure":"1074","dust_concentration":"415","air_purity":"DANGEROUS"} |
| 16 | +Response: Ok( |
| 17 | + Response { |
| 18 | + url: Url { |
| 19 | + scheme: "http", |
| 20 | + cannot_be_a_base: false, |
| 21 | + username: "", |
| 22 | + password: None, |
| 23 | + host: Some( |
| 24 | + Domain( |
| 25 | + "localhost", |
| 26 | + ), |
| 27 | + ), |
| 28 | + port: Some( |
| 29 | + 4000, |
| 30 | + ), |
| 31 | + path: "/api/readings/add", |
| 32 | + query: None, |
| 33 | + fragment: None, |
| 34 | + }, |
| 35 | + status: 200, |
| 36 | + headers: { |
| 37 | + "cache-control": "max-age=0, private, must-revalidate", |
| 38 | + "content-length": "60", |
| 39 | + "content-type": "application/json; charset=utf-8", |
| 40 | + "date": "Sat, 22 Jan 2022 19:25:14 GMT", |
| 41 | + "server": "Cowboy", |
| 42 | + "x-request-id": "FsyuNssWKjhYHbUAAAAj", |
| 43 | + }, |
| 44 | + }, |
| 45 | +) |
13 | 46 |
|
14 | 47 | # Or just |
15 | 48 |
|
16 | 49 | > cargo run |
17 | | -{"tempurature":"33.5","humidity":"39.6","pressure":"1100","dust_concentration":"8","air_purity":"FRESH_AIR"} |
18 | 50 | ``` |
19 | 51 |
|
20 | 52 | ### As an executable binary |
21 | | -```Rust |
| 53 | +```BASH |
22 | 54 | > cargo build |
23 | 55 | > ./target/debug/ambi_mock_client |
24 | | -{"tempurature":"25.9","humidity":"43.4","pressure":"1076","dust_concentration":"322","air_purity":"DANGEROUS"} |
| 56 | + |
| 57 | +Sending POST request to http://localhost:4000/api/readings/add as JSON: {"tempurature":"28.8","humidity":"85.2","pressure":"964","dust_concentration":"930","air_purity":"DANGEROUS"} |
| 58 | +Response: Ok( |
| 59 | + Response { |
| 60 | + url: Url { |
| 61 | + scheme: "http", |
| 62 | + cannot_be_a_base: false, |
| 63 | + username: "", |
| 64 | + password: None, |
| 65 | + host: Some( |
| 66 | + Domain( |
| 67 | + "localhost", |
| 68 | + ), |
| 69 | + ), |
| 70 | + port: Some( |
| 71 | + 4000, |
| 72 | + ), |
| 73 | + path: "/api/readings/add", |
| 74 | + query: None, |
| 75 | + fragment: None, |
| 76 | + }, |
| 77 | + status: 200, |
| 78 | + headers: { |
| 79 | + "cache-control": "max-age=0, private, must-revalidate", |
| 80 | + "content-length": "60", |
| 81 | + "content-type": "application/json; charset=utf-8", |
| 82 | + "date": "Sat, 22 Jan 2022 19:28:08 GMT", |
| 83 | + "server": "Cowboy", |
| 84 | + "x-request-id": "FsyuX1U1NOj9m7IAAABB", |
| 85 | + }, |
| 86 | + }, |
| 87 | +) |
25 | 88 | ``` |
0 commit comments