Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go:embed #7

Merged
merged 3 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=