From 81da1f1ab2cf65fc66bba1d51f8edfe66c7c85f6 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 2 Aug 2019 05:54:40 +0200 Subject: [PATCH] vweb: run app.init() once --- vlib/vweb/vweb.v | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 3f3799a146..36257fd1f6 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -88,6 +88,8 @@ $html pub fn run(port int) { println('Running vweb app on http://localhost:$port ...') l := net.listen(port) or { panic('failed to listen') return } + mut app := T{} + app.init() for { conn := l.accept() or { panic('accept() failed') @@ -138,16 +140,15 @@ pub fn run(port int) { method: vals[0] url: vals[1] } - mut app := T{ - vweb: Context{ - req: req - conn: conn - post_form: map[string]string{} - static_files: map[string]string{} - static_mime_types: map[string]string{} - } + //mut app := T{ + app.vweb = Context{ + req: req + conn: conn + post_form: map[string]string{} + static_files: map[string]string{} + static_mime_types: map[string]string{} } - app.init() + //} if req.method == 'POST' { app.vweb.parse_form(s) }