vweb: debug prints behind $if debug

pull/5095/head
Alexander Medvednikov 2020-06-10 11:50:06 +02:00
parent 931bba1d7d
commit b904d7d1ba
2 changed files with 11 additions and 9 deletions

View File

@ -17,10 +17,13 @@ fn main() {
vweb.run<App>(port)
}
pub fn (mut app App) init() {
pub fn (mut app App) init_once() {
app.vweb.handle_static('.')
}
pub fn (mut app App) init() {
}
pub fn (mut app App) json_endpoint() {
app.vweb.json('{"a": 3}')
}
@ -34,9 +37,6 @@ pub fn (mut app App) index() {
$vweb.html()
}
pub fn (mut app App) reset() {
}
pub fn (mut app App) text() {
app.vweb.text('Hello world from vweb')
}

View File

@ -134,7 +134,7 @@ pub fn run<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') }
app.vweb = Context{}
app.init_once()
@ -173,8 +173,10 @@ fn handle_conn<T>(conn net.Socket, mut app T) {
//mut app := app_
//first_line := strip(lines[0])
first_line := conn.read_line()
println('firstline="$first_line"')
$if debug { println(first_line) }
$if debug {
println('firstline="$first_line"')
}
// Parse the first line
// "GET / HTTP/1.1"
//first_line := s.all_before('\n')
@ -282,9 +284,9 @@ fn handle_conn<T>(conn net.Socket, mut app T) {
}
// Call the right action
//$if debug {
$if debug {
println('action=$action')
//}
}
app.init()
app.$action()
/*