-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.rd
More file actions
74 lines (65 loc) · 1.71 KB
/
test.rd
File metadata and controls
74 lines (65 loc) · 1.71 KB
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
config {
type = "http";
host = "127.0.0.1";
port = 8080;
};
import "E:/projects/rust/cli/target/release/plugin_name.dll" as std;
global_error_handler(error) {
Response.status(500);
Response.headers("Content-Type", "application/json");
Response.body("{\"error\": \"" + error + "\"}");
Response.send();
};
route "/test1" GET {
val a = 2;
val res = a + 2;
Response.body(res);
Response.send();
};
route "/test" GET {
val a = 2;
val b = 15 - 3;
while (a != 5) {
a += 1;
b -= 2;
};
Response.body("a = " + a + "b = " + b);
Response.send();
};
route "/test2" GET {
val mix = ["hello", "hey", 1, 2];
val body = "";
for (i in mix) {
body += i;
body += " ";
};
body += "\n";
body += array_length(mix);
body += "\n\n";
body += array_contains(mix, 1);
Response.body(body);
Response.send();
};
route "/test3" GET {
val a = std::is_email_valid("test@test.ru")?;
val b = std::is_ip_valid("127.0.0.1")?;
val c = std::env_var("PATH")?;
val d = std::random(1, 100)?;
val e = std::to_uppercase("this is lowercase")?;
val f = std::to_lowercase("THIS IS UPPERCASE")?;
val now = std::now()?;
std::sleep(2)?;
val after = std::now()?;
val res = "a = " + a + "\n" + "b = " + b + "\n" + "c = " + c + "\n" + "d = " + d + "\n" + "e = " + e + "\n" + "f = " + f + "\n\n" + "before = " + now + "\n" + "after = " + after;
if (a == "true" && b == "true") {
res += "\n\n\n";
res += "in if statement";
} else {
res += "\n\n\n";
res += "in else statement:\n";
res += a;
res += "\n" + b;
}
Response.body(res);
Response.send();
};