1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

comptime: fix $(field.name) in $for; vweb: shared fields

This commit is contained in:
Alexander Medvednikov
2021-06-16 20:33:30 +03:00
parent b2e2a53f98
commit eacdd0d7e1
5 changed files with 40 additions and 13 deletions

View File

@ -10,8 +10,13 @@ const (
struct App {
vweb.Context
port int
timeout int
port int
timeout int
global_config shared Config
}
struct Config {
max_ping int
}
fn exit_after_timeout(timeout_in_ms int) {
@ -30,9 +35,13 @@ fn main() {
assert timeout > 0
go exit_after_timeout(timeout)
//
shared config := &Config{
max_ping: 50
}
app := &App{
port: http_port
timeout: timeout
global_config: config
}
eprintln('>> webserver: started on http://127.0.0.1:$app.port/ , with maximum runtime of $app.timeout milliseconds.')
// vweb.run<App>(mut app, http_port)
@ -43,6 +52,7 @@ fn main() {
//}
pub fn (mut app App) index() vweb.Result {
assert app.global_config.max_ping == 50
return app.text('Welcome to VWeb')
}