Skip to content

Commit

Permalink
article
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jan 6, 2024
1 parent f53de82 commit f3e013a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Go+ Community
Go+ Community written in Go+
=====

[![Build Status](https://github.com/goplus/community/actions/workflows/go.yml/badge.svg)](https://github.com/goplus/community/actions/workflows/go.yml)
Expand Down
7 changes: 6 additions & 1 deletion cmd/gopcomm/community.gop
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ var yapFS embed.FS
fsYap := fs.sub(yapFS, "yap")!
y := yap.new(fsYap)

y.handle "/p/", ctx => {
y.GET "/p/:id", ctx => {
ctx.YAP 200, "article", yap.H{
"id": ctx.param("id"),
}
}

y.run ":8080"
28 changes: 16 additions & 12 deletions cmd/gopcomm/gop_autogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,31 @@ import (
)
//go:embed yap
var yapFS embed.FS
//line cmd/gopcomm/community.gop:11
//line community.gop:11
func main() {
//line cmd/gopcomm/community.gop:11:1
//line community.gop:11:1
fsYap := func() (_gop_ret fs.FS) {
//line cmd/gopcomm/community.gop:11:1
//line community.gop:11:1
var _gop_err error
//line cmd/gopcomm/community.gop:11:1
//line community.gop:11:1
_gop_ret, _gop_err = fs.Sub(yapFS, "yap")
//line cmd/gopcomm/community.gop:11:1
//line community.gop:11:1
if _gop_err != nil {
//line cmd/gopcomm/community.gop:11:1
_gop_err = errors.NewFrame(_gop_err, "fs.sub(yapFS, \"yap\")", "cmd/gopcomm/community.gop", 11, "main.main")
//line cmd/gopcomm/community.gop:11:1
//line community.gop:11:1
_gop_err = errors.NewFrame(_gop_err, "fs.sub(yapFS, \"yap\")", "community.gop", 11, "main.main")
//line community.gop:11:1
panic(_gop_err)
}
//line cmd/gopcomm/community.gop:11:1
//line community.gop:11:1
return
}()
//line cmd/gopcomm/community.gop:12:1
//line community.gop:12:1
y := yap.New(fsYap)
//line cmd/gopcomm/community.gop:14:1
y.Handle("/p/", func(ctx *yap.Context) {
//line community.gop:14:1
y.GET("/p/:id", func(ctx *yap.Context) {
//line community.gop:15:1
ctx.YAP(200, "article", yap.H{"id": ctx.Param("id")})
})
//line community.gop:20:1
y.Run(":8080")
}
8 changes: 8 additions & 0 deletions cmd/gopcomm/yap/article.yap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
Article {{.id}}
</body>
</html>
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/goplus/community
go 1.18

require (
github.com/goplus/yap v0.1.0
github.com/qiniu/x v1.13.2
github.com/goplus/yap v0.2.0
github.com/qiniu/x v1.13.2
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github.com/goplus/yap v0.1.0 h1:POiEaS0ZlHPOo6Vw8guq+i9sOUfzF3ZHiSmK0NC+9I8=
github.com/goplus/yap v0.1.0/go.mod h1:VCbGlZo2lUgRWciTZwA5JEOuCUf8T2PhxZZ0HXqzgBk=
github.com/goplus/yap v0.2.0 h1:0RLQBxBOiUxKb+9AY/yhYtlnQKjfPyaOhDv720S1Izk=
github.com/goplus/yap v0.2.0/go.mod h1:VCbGlZo2lUgRWciTZwA5JEOuCUf8T2PhxZZ0HXqzgBk=
github.com/qiniu/x v1.13.2 h1:mgWOfB9Rpk6AEtlBoObZVxH+b2FHSntYrxc4KX5Ta98=
github.com/qiniu/x v1.13.2/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E=

0 comments on commit f3e013a

Please sign in to comment.