changeset 1689:af22d6c120e4

improve http/serve.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 12 Jun 2022 18:48:01 -0600
parents 5eb985d1411f
children 973d3039c421
files src/luan/modules/http/serve.luan
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/http/serve.luan	Sat Jun 11 21:14:19 2022 +0200
+++ b/src/luan/modules/http/serve.luan	Sun Jun 12 18:48:01 2022 -0600
@@ -5,11 +5,15 @@
 local String = require "luan:String.luan"
 local to_number = String.to_number or error()
 
-local count = #{...}
+local dir, port, extra = ...
 
-if count < 1 or count > 2 then
-	Io.stderr.write "usage: luan luan:http/serve.luan dir port\n"
+if dir==nil or extra~=nil then
+	Io.stderr.write "usage: luan luan:http/serve.luan dir [port]\n"
 	return
 end
 
-Server.serve({...}[1],to_number({...}[2]))
\ No newline at end of file
+if port ~= nil then
+	port = to_number(port) or error "port must be an integer"
+end
+
+Server.serve(dir,port)