aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramelia squires <[email protected]>2024-09-04 12:49:26 -0500
committeramelia squires <[email protected]>2024-09-04 12:49:26 -0500
commit86fbbbc48b76436cddd08b04bd0d751c6e51d29f (patch)
tree7db98d7a70b54d05140f3fca31b0499fd1bd38d6
parentaf2da4242cfe192e49ee490d8dd3a3b7fff02000 (diff)
net rewrite docs
-rw-r--r--docs/net.md28
1 files changed, 27 insertions, 1 deletions
diff --git a/docs/net.md b/docs/net.md
index 474cdbe..e548cb1 100644
--- a/docs/net.md
+++ b/docs/net.md
@@ -30,7 +30,7 @@ server:unlock()
...
```
-### server:close
+### server:close **
closes server
@@ -41,6 +41,8 @@ closes server
the function has 2 arguments, the first (res) contains functions and info about resolving the request,
the second (req) contains info on the request, the path allows for wildcards, multiple get requests per path is allowed
+it also allows for path paramaters which is a wildcard directory that pushes the results into req.paramaters (read below)
+
the actual name of the function will change based on what request method you want to accept, all requests are treated the exact same on the backend, besides HEAD requests which will also use all GET requets, and the 'all' variant will get everything
```lua
@@ -56,6 +58,10 @@ server:GET("/", function(res, req)
...
end)
...
+
+server:GET("/home/{user}/id", function(res, req)
+ --sets req.paramaters.user to whatever path was requested
+end)
```
#### res:write
@@ -119,6 +125,26 @@ res:sendfile("./html/index.html")
...
```
+### req.paramaters
+
+a list of paramaters for the current function
+
+a path of '/user/{name}/id'
+and a request of '/user/amelia/id'
+would set req.paramaters.name to amelia
+
+currently you can not have multiple paramaters per directory
+
+> this could be changed in later versions
+
+/home/{name} is valid
+
+/flight/{id}-{airline} is not
+
+these can, of course be used with wildcards however you want
+
+/*/{user}/id would match /a/b/c/meow/id with req.paramaters.user being equal to meow
+
### req:roll
'takes an integer of bytes to read & parse (optional, otherwise the max amount of bytes will be read)