mirror of
https://github.com/vlang/v.git
synced 2025-09-07 22:30:57 -04:00
tutorials: fix compilation errors in Building a simple web blog with Veb
(#24631)
This commit is contained in:
parent
056998a42a
commit
aaf3d3315d
@ -102,8 +102,8 @@ no routing rules either:
|
|||||||
import veb
|
import veb
|
||||||
import time
|
import time
|
||||||
|
|
||||||
fn (mut app App) time() veb.Result {
|
fn (app &App) time(mut ctx Context) veb.Result {
|
||||||
return app.text(time.now().format())
|
return ctx.text(time.now().format())
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ and update our `index()` action so that it returns the HTML view we just created
|
|||||||
|
|
||||||
```v ignore
|
```v ignore
|
||||||
// blog.v
|
// blog.v
|
||||||
pub fn (mut app App) index() veb.Result {
|
pub fn (app &App) index(mut ctx Context) veb.Result {
|
||||||
message := 'Hello, world from Vweb!'
|
message := 'Hello, world from Vweb!'
|
||||||
return $veb.html()
|
return $veb.html()
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ Next we need to add the HTML endpoint to our code like we did with `index.html`:
|
|||||||
|
|
||||||
```v ignore
|
```v ignore
|
||||||
@['/new']
|
@['/new']
|
||||||
pub fn (mut app App) new() veb.Result {
|
pub fn (app &App) new() veb.Result {
|
||||||
return $veb.html()
|
return $veb.html()
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -392,9 +392,9 @@ in V is very simple:
|
|||||||
import veb
|
import veb
|
||||||
|
|
||||||
@['/articles'; get]
|
@['/articles'; get]
|
||||||
pub fn (mut app App) articles() veb.Result {
|
pub fn (app &App) articles(mut ctx Context) veb.Result {
|
||||||
articles := app.find_all_articles()
|
articles := app.find_all_articles()
|
||||||
return app.json(articles)
|
return ctx.json(articles)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user