Skip to content

Commit 0146509

Browse files
authored
examples: fullstack vweb example (#16761)
1 parent 43d8bc3 commit 0146509

27 files changed

+759
-0
lines changed

cmd/tools/vbuild-examples.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const vroot = @VMODROOT
99
const efolders = [
1010
'examples/viewer',
1111
'examples/vweb_orm_jwt',
12+
'examples/vweb_fullstack',
1213
]
1314

1415
fn main() {

examples/vweb_fullstack/.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[*]
2+
charset = utf-8
3+
end_of_line = lf
4+
insert_final_newline = true
5+
trim_trailing_whitespace = true
6+
7+
[*.v]
8+
indent_style = tab
9+
indent_size = 4
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* text=auto eol=lf
2+
*.bat eol=crlf
3+
4+
**/*.v linguist-language=V
5+
**/*.vv linguist-language=V
6+
**/*.vsh linguist-language=V
7+
**/v.mod linguist-language=V

examples/vweb_fullstack/.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Binaries for programs and plugins
2+
main
3+
batata
4+
*.exe
5+
*.exe~
6+
*.so
7+
*.dylib
8+
*.dll
9+
*.sql
10+
11+
# Ignore binary output folders
12+
bin/
13+
14+
# Ignore common editor/system specific metadata
15+
.DS_Store
16+
.idea/
17+
.vscode/
18+
*.iml

examples/vweb_fullstack/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Hitalo Souza
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
15 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Loading
303 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module main
2+
3+
import vweb
4+
5+
['/controller/auth'; post]
6+
pub fn (mut app App) controller_auth(username string, password string) vweb.Result {
7+
response := app.service_auth(username, password) or {
8+
app.set_status(400, '')
9+
return app.text('error: ${err}')
10+
}
11+
12+
return app.json(response)
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module main
2+
3+
struct AuthRequestDto {
4+
username string [required]
5+
password string [required]
6+
}

0 commit comments

Comments
 (0)