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

examples: show how to use a before_request method for the multi-route examples, be more informative about DB creation problems (#16279)

This commit is contained in:
Hitalo Souza 2022-11-01 14:02:07 -03:00 committed by GitHub
parent 0c03ebb7a4
commit d2902e700f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -18,6 +18,10 @@ mut:
cnt int cnt int
} }
pub fn (app App) before_request() {
println('[Vweb] $app.Context.req.method $app.Context.req.url')
}
fn main() { fn main() {
println('vweb example') println('vweb example')
vweb.run(&App{}, port) vweb.run(&App{}, port)

View File

@ -11,12 +11,16 @@ struct App {
vweb.Context vweb.Context
} }
pub fn (app App) before_request() {
println('[Vweb] $app.Context.req.method $app.Context.req.url')
}
fn main() { fn main() {
mut db := databases.create_db_connection() or { panic(err) } mut db := databases.create_db_connection() or { panic(err) }
sql db { sql db {
create table User create table User
} } or { panic('error on create table: $err') }
db.close() or { panic(err) } db.close() or { panic(err) }