From fbd90fbd1b677bf0f5f952628e995a8c7bbd1571 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 14 Nov 2018 02:44:19 +0100 Subject: license: Add thank-you page at `/license` --- license-generator/src/bin/license.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'license-generator/src') diff --git a/license-generator/src/bin/license.rs b/license-generator/src/bin/license.rs index f35407b..c68d299 100644 --- a/license-generator/src/bin/license.rs +++ b/license-generator/src/bin/license.rs @@ -39,7 +39,7 @@ struct LicenseData<'a> { } trait LicenseValidationResponse { - fn success(&mut self, name: &str, email: &str); + fn success(&mut self, name: &str, email: &str, secret: &str); fn error_400(&mut self); fn error_404(&mut self); fn error_500(&mut self, error: Option); @@ -51,7 +51,18 @@ struct HtmlResponse<'a, W: 'a> { impl<'a, W> LicenseValidationResponse for HtmlResponse<'a, W> where W: 'a + Write { - fn success(&mut self, name: &str, email: &str) { + fn success(&mut self, name: &str, email: &str, secret: &str) { + write!( + self.writer, + "Status: 200 +Content-Type: text/html\n\n{}", + format!( + include_str!("../../../thank-you.html"), + name = name, + email = email, + secret = secret, + ) + ).unwrap_or(()) } fn error_400(&mut self) { @@ -80,7 +91,7 @@ struct ZipResponse<'a, W: 'a> { impl<'a, W> LicenseValidationResponse for ZipResponse<'a, W> where W: 'a + Write { - fn success(&mut self, name: &str, email: &str) { + fn success(&mut self, name: &str, email: &str, _secret: &str) { let license_data = LicenseData { name: &name, email: &email, @@ -171,7 +182,7 @@ fn build_response<'a, R: LicenseValidationResponse>( Err(e) => return responses.error_500(Some(e.into())), }; - return responses.success(&name, &email); + return responses.success(&name, &email, &secret); } else { return responses.error_404(); } -- cgit v1.2.3 ption>
path: root/sha1/configure.ac
blob: 5d59beba3f67ba44715376e822eb6cc6b19c62a9 (plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156