diff options
| author | ame <[email protected]> | 2024-01-29 16:06:48 -0600 |
|---|---|---|
| committer | ame <[email protected]> | 2024-01-29 16:06:48 -0600 |
| commit | f4227f79e03269fde857a3a0e601e6e61bee4db6 (patch) | |
| tree | 7da6cd9507674a3e6ee354f0cc6124d02a99d8c5 /docs/net.md | |
| parent | e1c171c9c87cf80578a262310510cf6958066b47 (diff) | |
docs and speed
Diffstat (limited to 'docs/net.md')
| -rw-r--r-- | docs/net.md | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/docs/net.md b/docs/net.md new file mode 100644 index 0000000..79535c3 --- /dev/null +++ b/docs/net.md @@ -0,0 +1,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
+
|
