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:
@ -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')
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user