aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authoramelia squires <[email protected]>2024-09-08 05:13:11 -0500
committeramelia squires <[email protected]>2024-09-08 05:13:11 -0500
commiteda53f915dc319cec7a4fe680734db87a113fe5e (patch)
tree57368ce9ae49e89809171dc6ae85fde936a2b5f2 /docs
parent4523c0c2ae946e1e5c982a01c961d3aaacd7858a (diff)
parent86fbbbc48b76436cddd08b04bd0d751c6e51d29f (diff)
merge rewrite-net-route-matching
Diffstat (limited to '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)