Skip to content

Commit

Permalink
vweb: support a startup_message field too in app.run_at
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Dec 11, 2023
1 parent 2de9a24 commit 423b34f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vlib/vweb/vweb.v
Expand Up @@ -518,6 +518,7 @@ pub struct RunParams {
nr_workers int = runtime.nr_jobs()
pool_channel_slots int = 1000
show_startup_message bool = true
startup_message string
}

// run_at - start a new VWeb server, listening only on a specific address `host`, at the specified `port`
Expand All @@ -544,9 +545,13 @@ pub fn run_at[T](global_app &T, params RunParams) ! {
routes := generate_routes(global_app)!
controllers_sorted := check_duplicate_routes_in_controllers[T](global_app, routes)!

host := if params.host == '' { 'localhost' } else { params.host }
if params.show_startup_message {
println('[Vweb] Running app on http://${host}:${params.port}/')
if params.startup_message == '' {
host := if params.host == '' { 'localhost' } else { params.host }
println('[Vweb] Running app on http://${host}:${params.port}/')
} else {
println(params.startup_message)
}
}

ch := chan &RequestParams{cap: params.pool_channel_slots}
Expand Down

0 comments on commit 423b34f

Please sign in to comment.