vweb: run app.init() once

pull/1427/head^2
Alexander Medvednikov 2019-08-02 05:54:40 +02:00
parent 8ecd62e56f
commit 81da1f1ab2
1 changed files with 10 additions and 9 deletions

View File

@ -88,6 +88,8 @@ $html
pub fn run<T>(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<T>(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)
}