From 347da823b7e3b5431318bf231835fe35ec9ab18c Mon Sep 17 00:00:00 2001 From: vocksel Date: Sat, 3 Feb 2024 11:43:40 -0800 Subject: [PATCH] Update `net.serve` docs for `address` change (#149) --- types/net.luau | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/types/net.luau b/types/net.luau index 4f45a00..47c6249 100644 --- a/types/net.luau +++ b/types/net.luau @@ -113,12 +113,28 @@ type ServeWebSocketHandler = (socket: WebSocket) -> () Configuration for `net.serve`. - This may contain one of, or both of the following callbacks: + This may contain one of or more of the following values: + * `address` for setting the IP address to serve from. Defaults to the loopback interface (`http://localhost`). * `handleRequest` for handling normal http requests, equivalent to just passing a function to `net.serve` * `handleWebSocket` for handling web socket requests, which will receive a `WebSocket` object as its first and only parameter + + When setting `address`, the `handleRequest` callback must also be defined. + + ```lua + net.serve(8080, { + address = "http://0.0.0.0", + handleRequest = function(request) + return { + status = 200, + body = "Echo:\n" .. request.body, + } + end + }) + ``` ]=] export type ServeConfig = { + address: string?, handleRequest: ServeHttpHandler?, handleWebSocket: ServeWebSocketHandler?, }