mirror of
https://github.com/Open-Argon/http.ar.git
synced 2026-10-28 09:43:55 +00:00
fix bug where error isnt thrown then server couldnt boot
This commit is contained in:
1 parent
66bfd826ee
commit
1299508ef1
6 files changed
+35
-16
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"name": "http.ar",
|
||||
"version": "1.1.1"
|
||||
"version": "1.1.2"
|
||||
}
|
||||
@@ -12,14 +12,12 @@ app.use(http.static("/",path.join([path.parent(program.file.path),"static"])))
|
||||
|
||||
let form(req, res) = do
|
||||
term.log(req, res)
|
||||
if (req.method == "POST") do
|
||||
term.log(req.formdata)
|
||||
term.log(req.files)
|
||||
res.send("POST")
|
||||
return
|
||||
|
||||
res.send("<form method='POST' enctype='multipart/form-data'><input type='text' name='text'><input type='file' name='file'><input type='submit'></form>")
|
||||
app.all("/form", form)
|
||||
let form_post(req, res) = do
|
||||
term.log(req.formdata)
|
||||
term.log(req.files)
|
||||
res.send("POST")
|
||||
app.route("/form").get(form).post(form_post)
|
||||
|
||||
let err404(req, res) = do
|
||||
res.code = 404
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import "../../src" as http
|
||||
|
||||
let app = http.server()
|
||||
|
||||
app.use(http.logger)
|
||||
|
||||
app.use(http.formdata)
|
||||
|
||||
app.port = 3000
|
||||
|
||||
app.run()
|
||||
+1
-1
@@ -1 +1 @@
|
||||
[{"Name":"neon.ar","Version":"beta1.0.2","URL":"https://isotope.wbell.dev/isotope-download?name=neon.ar\u0026version=beta1.0.2","Remote":"isotope.wbell.dev"},{"Name":"url.ar","Version":"1.0.1","URL":"https://isotope.wbell.dev/isotope-download?name=url.ar\u0026version=1.0.1","Remote":"isotope.wbell.dev"}]
|
||||
[{"Name":"neon.ar","Version":"beta1.0.2","URL":"https://isotope.wbell.dev/isotope-download?name=neon.ar\u0026version=beta1.0.2","Remote":"isotope.wbell.dev"},{"Name":"url.ar","Version":"1.0.2","URL":"https://isotope.wbell.dev/isotope-download?name=url.ar\u0026version=1.0.2","Remote":"isotope.wbell.dev"},{"Name":"http.ar","Version":"1.1.2","URL":"https://isotope.wbell.dev/isotope-download?name=http.ar\u0026version=1.1.2","Remote":"isotope.wbell.dev"}]
|
||||
+1
-1
@@ -14,7 +14,7 @@ let __multipart(req, res) = do
|
||||
let newLineSplit = buffer().from("\r\n\r\n")
|
||||
let parts = req.buffer.body.split(boundary)
|
||||
for (i from 0 to parts.length) do
|
||||
let str = (parts[i].to("string"))
|
||||
let str = parts[i].to("string")
|
||||
if (str == "" || str=="--" || str=="--\r\n") continue
|
||||
str = null
|
||||
let headers = {}
|
||||
|
||||
+16
-6
@@ -25,8 +25,8 @@ let server() = do
|
||||
class.run() = do
|
||||
if (Socket != null) do
|
||||
throwError("Server already running")
|
||||
Socket = socket.server("tcp", class.port)
|
||||
let starter() = do
|
||||
Socket = socket.server("tcp", class.port)
|
||||
thread(()=listener.listener(Socket, routes, class.onErr)).start()
|
||||
class.callback()
|
||||
let t = thread(starter)
|
||||
@@ -36,11 +36,21 @@ let server() = do
|
||||
|
||||
class.route(path) = do
|
||||
let class = {}
|
||||
class.get(callback) = routes.append({path: path, callback: callback, methods: ["GET"], type: "route"})
|
||||
class.post(callback) = routes.append({path: path, callback: callback, methods: ["POST"], type: "route"})
|
||||
class.put(callback) = routes.append({path: path, callback: callback, methods: ["PUT"], type: "route"})
|
||||
class.delete(callback) = routes.append({path: path, callback: callback, methods: ["DELETE"], type: "route"})
|
||||
class.all(callback) = routes.append({path: path, callback: callback, methods: true, type: "route"})
|
||||
class.get(callback) = do
|
||||
routes.append({path: path, callback: callback, methods: ["GET"], type: "route"})
|
||||
return class
|
||||
class.post(callback) = do
|
||||
routes.append({path: path, callback: callback, methods: ["POST"], type: "route"})
|
||||
return class
|
||||
class.put(callback) = do
|
||||
routes.append({path: path, callback: callback, methods: ["PUT"], type: "route"})
|
||||
return class
|
||||
class.delete(callback) = do
|
||||
routes.append({path: path, callback: callback, methods: ["DELETE"], type: "route"})
|
||||
return class
|
||||
class.all(callback) = do
|
||||
routes.append({path: path, callback: callback, methods: true, type: "route"})
|
||||
return class
|
||||
return class
|
||||
class.get(path, callback) = class.route(path).get(callback)
|
||||
class.post(path, callback) = class.route(path).post(callback)
|
||||
|
||||
Reference in new issue
Block a user