mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: init_once()
This commit is contained in:
parent
2dc547a45c
commit
2ed4457c5f
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user