Skip to content

Commit

Permalink
Merge pull request #7 from xushiwei/yap
Browse files Browse the repository at this point in the history
go:embed
  • Loading branch information
xushiwei committed Jan 6, 2024
2 parents 8ff9254 + 4afdffe commit f7cbf55
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 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"
8 changes: 6 additions & 2 deletions cmd/gopcomm/gop_autogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/goplus/yap"
"github.com/qiniu/x/errors"
)

//go:embed yap
var yapFS embed.FS
//line cmd/gopcomm/community.gop:11
func main() {
Expand All @@ -29,6 +29,10 @@ func main() {
//line cmd/gopcomm/community.gop:12:1
y := yap.New(fsYap)
//line cmd/gopcomm/community.gop:14:1
y.Handle("/p/", func(ctx *yap.Context) {
y.GET("/p/:id", func(ctx *yap.Context) {
//line cmd/gopcomm/community.gop:15:1
ctx.YAP(200, "article", yap.H{"id": ctx.Param("id")})
})
//line cmd/gopcomm/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 f7cbf55

Please sign in to comment.