Skip to content

Commit d8ecff1

Browse files
koplenovwaghanza
andauthored
v | added x.vweb (the-benchmarker#7136)
Co-authored-by: Marwan <[email protected]>
1 parent ee301c1 commit d8ecff1

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

v/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ RUN v . {{#build_flags}} {{{.}}} {{/build_flags}} -o server
2525

2626
FROM debian
2727

28+
{{#build_deps.length}}
29+
ARG DEBIAN_FRONTEND=noninteractive
30+
RUN apt-get -y update
31+
32+
{{#build_deps}}
33+
RUN apt-get -y install {{{.}}}
34+
{{/build_deps}}
35+
36+
{{/build_deps.length}}
37+
2838
WORKDIR /app
2939

3040
COPY --from=build /app /app

v/x.vweb/config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
framework:
2+
github: vlang/v
3+
version: 0.4
4+
5+
build_deps:
6+
- libatomic1

v/x.vweb/main.v

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import x.vweb
2+
3+
pub struct App {}
4+
5+
pub struct Context {
6+
vweb.Context
7+
}
8+
9+
fn main() {
10+
mut app := &App{}
11+
vweb.run[App, Context](mut app, 3000)
12+
}
13+
14+
@['/']
15+
fn (mut app App) index(mut ctx Context) vweb.Result {
16+
return ctx.text('')
17+
}
18+
19+
@['/user/:id']
20+
fn (mut app App) get_user_id(mut ctx Context, id string) vweb.Result {
21+
return ctx.text(id)
22+
}
23+
24+
@['/user'; post]
25+
fn (mut app App) post_user(mut ctx Context) vweb.Result {
26+
return ctx.text('')
27+
}

0 commit comments

Comments
 (0)