mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: debug prints behind $if debug
This commit is contained in:
parent
931bba1d7d
commit
b904d7d1ba
@ -17,10 +17,13 @@ fn main() {
|
|||||||
vweb.run<App>(port)
|
vweb.run<App>(port)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut app App) init() {
|
pub fn (mut app App) init_once() {
|
||||||
app.vweb.handle_static('.')
|
app.vweb.handle_static('.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn (mut app App) init() {
|
||||||
|
}
|
||||||
|
|
||||||
pub fn (mut app App) json_endpoint() {
|
pub fn (mut app App) json_endpoint() {
|
||||||
app.vweb.json('{"a": 3}')
|
app.vweb.json('{"a": 3}')
|
||||||
}
|
}
|
||||||
@ -34,9 +37,6 @@ pub fn (mut app App) index() {
|
|||||||
$vweb.html()
|
$vweb.html()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut app App) reset() {
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut app App) text() {
|
pub fn (mut app App) text() {
|
||||||
app.vweb.text('Hello world from vweb')
|
app.vweb.text('Hello world from vweb')
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ pub fn run<T>(port int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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_once()
|
app.init_once()
|
||||||
@ -173,8 +173,10 @@ fn handle_conn<T>(conn net.Socket, mut app T) {
|
|||||||
//mut app := app_
|
//mut app := app_
|
||||||
//first_line := strip(lines[0])
|
//first_line := strip(lines[0])
|
||||||
first_line := conn.read_line()
|
first_line := conn.read_line()
|
||||||
|
$if debug {
|
||||||
println('firstline="$first_line"')
|
println('firstline="$first_line"')
|
||||||
$if debug { println(first_line) }
|
}
|
||||||
|
|
||||||
// Parse the first line
|
// Parse the first line
|
||||||
// "GET / HTTP/1.1"
|
// "GET / HTTP/1.1"
|
||||||
//first_line := s.all_before('\n')
|
//first_line := s.all_before('\n')
|
||||||
@ -282,9 +284,9 @@ fn handle_conn<T>(conn net.Socket, mut app T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Call the right action
|
// Call the right action
|
||||||
//$if debug {
|
$if debug {
|
||||||
println('action=$action')
|
println('action=$action')
|
||||||
//}
|
}
|
||||||
app.init()
|
app.init()
|
||||||
app.$action()
|
app.$action()
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user