File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -15,23 +15,28 @@ http server that listens on port 3333:
15
15
= begin code :skip-test<IO>
16
16
react {
17
17
whenever IO::Socket::Async.listen('0.0.0.0', 3333) -> $conn {
18
- whenever $conn.Supply.lines {
19
- say .Str;
20
-
21
- { try $conn.print(.Str ~ "\n") } for
22
- "HTTP/1.1 200 OK",
23
- "Content-Type: text/html; charset=UTF-8",
24
- "Content-Encoding: UTF-8",
25
- "",
26
- "<html><body>Hello World!</body></html>";
27
-
18
+ whenever $conn.Supply.lines -> $line {
19
+ $conn.print: qq:heredoc/END/;
20
+ HTTP/1.1 200 OK
21
+ Content-Type: text/html; charset=UTF-8
22
+ Content-Encoding: UTF-8
23
+
24
+ <html>
25
+ <body>
26
+ <h1>Hello World!</h1>
27
+ <p>{ $line }</p>
28
+ </body>
29
+ </html>
30
+ END
28
31
$conn.close;
29
32
}
30
- CLOSE {
31
- note „{now} connection closed“;
33
+ }
34
+ CATCH {
35
+ default {
36
+ say .^name, ': ', .Str;
37
+ say "handled in $?LINE";
32
38
}
33
39
}
34
- CATCH { default { say .^name, ': ', .Str; say "handled in $?LINE"; } }
35
40
}
36
41
= end code
37
42
You can’t perform that action at this time.
0 commit comments