We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e08c004 commit 15368a3Copy full SHA for 15368a3
1 file changed
vlib/fasthttp/README.md
@@ -29,11 +29,26 @@ import fasthttp
29
fn handle_request(req fasthttp.HttpRequest) ![]u8 {
30
path := req.buffer[req.path.start..req.path.start + req.path.len].bytestr()
31
32
+ mut body := ''
33
+ mut status_line := ''
34
+
35
if path == '/' {
- return 'Hello, World!'.bytes()
36
+ body = 'Hello, World!\n'
37
+ status_line = 'HTTP/1.1 200 OK'
38
+ } else {
39
+ body = '${path} not found\n'
40
+ status_line = 'HTTP/1.1 404 Not Found'
41
}
42
- return '404 Not Found'.bytes()
43
+ headers := [
44
+ status_line,
45
+ 'Content-Type: text/plain',
46
+ 'Content-Length: ${body.len}',
47
+ 'Connection: close',
48
+ ]
49
+ header_string := headers.join('\r\n')
50
51
+ return '${header_string}\r\n\r\n${body}'.bytes()
52
53
54
fn main() {
0 commit comments