Created
July 25, 2021 08:21
-
-
Save takkyuuplayer/4887f27ec80245fc120d6aefc7636ea0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module main | |
| import vweb | |
| struct App { | |
| vweb.Context | |
| alphabets []string | |
| } | |
| fn new_app(alphabets []string) &App { | |
| assert alphabets == ['a', 'b', 'c'] | |
| return &App{ | |
| alphabets: alphabets | |
| } | |
| } | |
| fn (mut app App) index() vweb.Result { | |
| return app.text('alphabets: ${app.alphabets}') | |
| } | |
| fn main() { | |
| vweb.run(new_app(['a', 'b', 'c']), 8080) | |
| } |
Author
Author
I found changing alphabets to shared works, while I'm not sure if it's the right approach.
module main
import vweb
struct App {
vweb.Context
mut:
alphabets shared []string
}
fn new_app(alphabets []string) &App {
assert alphabets == ['a', 'b', 'c']
mut app := &App{}
lock app.alphabets {
app.alphabets = alphabets
}
return app
}
fn (mut app App) index() vweb.Result {
text := rlock app.alphabets {
'alphabets: $app.alphabets'
}
return app.text(text)
}
fn main() {
vweb.run(new_app(['a', 'b', 'c']), 8080)
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pub mut:didn't help. Why can gitly use thedbvariable in the controller actions?