From b904d7d1ba22827e356c044a717ac96822dde255 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 10 Jun 2020 11:50:06 +0200 Subject: [PATCH] vweb: debug prints behind $if debug --- examples/vweb/vweb_example.v | 8 ++++---- vlib/vweb/vweb.v | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/vweb/vweb_example.v b/examples/vweb/vweb_example.v index 26e89a6841..158ef62461 100644 --- a/examples/vweb/vweb_example.v +++ b/examples/vweb/vweb_example.v @@ -17,10 +17,13 @@ fn main() { vweb.run(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') } diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 76b2569641..10ba8f5690 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -134,7 +134,7 @@ pub fn run(port int) { } pub fn run_app(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(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(conn net.Socket, mut app T) { } // Call the right action - //$if debug { + $if debug { println('action=$action') - //} + } app.init() app.$action() /*