vweb: init_once()

pull/5095/head
Alexander Medvednikov 2020-06-10 11:23:41 +02:00
parent 2dc547a45c
commit 2ed4457c5f
1 changed files with 4 additions and 3 deletions

View File

@ -131,13 +131,13 @@ pub fn (ctx &Context) get_header(key string) string {
pub fn run<T>(port int) { pub fn run<T>(port int) {
mut app := T{} mut app := T{}
run_app<T>(mut app, port) run_app<T>(mut app, port)
} }
pub fn run_app<T>(mut app T, port int) { pub fn run_app<T>(mut app T, port int) {
println('Running a Vweb app on http://localhost:$port ...') println('Running a Vweb app on http://localhost:$port ...')
l := net.listen(port) or { panic('failed to listen') } l := net.listen(port) or { panic('failed to listen') }
app.vweb = Context{} app.vweb = Context{}
app.init() app.init_once()
//app.reset() //app.reset()
for { for {
conn := l.accept() or { panic('accept() failed') } conn := l.accept() or { panic('accept() failed') }
@ -285,6 +285,7 @@ fn handle_conn<T>(conn net.Socket, mut app T) {
//$if debug { //$if debug {
println('action=$action') println('action=$action')
//} //}
app.init()
app.$action() app.$action()
/* /*
app.$action() or { app.$action() or {
@ -292,7 +293,7 @@ fn handle_conn<T>(conn net.Socket, mut app T) {
} }
*/ */
conn.close() or {} conn.close() or {}
app.reset() //app.reset()
return return
} }