blob: 79535c3eb71b5b3b8fbb8761d3ea1b9c06ccbad8 (
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
|
# net
## listen (PARTIALLY IMPLEMENTED)
'takes a function with 1 argument and a integer for a port
the function will be ran on initilization, the argument has info on the server and functions to set it up
```lua
llib.net.listen(function(server)
...
end, 80)
```
### server:GET
'takes a string (the path) and a function to be ran in the background on request
the function has 2 arguments, the first (res) contains functions and info about resolving the request,
the second (req) contains info on the request
```lua
...
server:GET("/", function(res, req) do
...
end)
...
```
#### res:send
'takes a string
sends the string to the client
```lua
...
res:send("<h1>hello world</h1>")
...
```
#### res:set **
'takes 2 strings, key and value
set the key to value in the response header, certain keys will affect other values or have other side effects on res:send, listed below
|key|side effect|
|--|--|
|Code|Changes response note, ie: (200: OK)|
```lua
...
res:set("Content-Type", "text/html") -- Content-Type: text/html
...
```
#### res:close()
closes connection
|