Skip to content

Commit

Permalink
use yap classfile
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jan 7, 2024
1 parent c78ce31 commit cb36d7e
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 69 deletions.
24 changes: 0 additions & 24 deletions cmd/gopcomm/community.gop

This file was deleted.

10 changes: 10 additions & 0 deletions cmd/gopcomm/community_yap.gox
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
get "/p/:id", ctx => {
ctx.yap "article", {
"id": ctx.param("id"),
}
}
get "/", ctx => {
ctx.yap "home", {}
}

run ":8080"
56 changes: 20 additions & 36 deletions cmd/gopcomm/gop_autogen.go
Original file line number Diff line number Diff line change
@@ -1,42 +1,26 @@
package main

import (
"embed"
"io/fs"
"github.com/goplus/yap"
"github.com/qiniu/x/errors"
)
import "github.com/goplus/yap"

type article struct {
ID string
type community_yap struct {
yap.App
}
//go:embed yap
var yapFS embed.FS
//line cmd/gopcomm/community.gop:15
func main() {
//line cmd/gopcomm/community.gop:15:1
fsYap := func() (_gop_ret fs.FS) {
//line cmd/gopcomm/community.gop:15:1
var _gop_err error
//line cmd/gopcomm/community.gop:15:1
_gop_ret, _gop_err = fs.Sub(yapFS, "yap")
//line cmd/gopcomm/community.gop:15:1
if _gop_err != nil {
//line cmd/gopcomm/community.gop:15:1
_gop_err = errors.NewFrame(_gop_err, "fs.sub(yapFS, \"yap\")", "cmd/gopcomm/community.gop", 15, "main.main")
//line cmd/gopcomm/community.gop:15:1
panic(_gop_err)
}
//line cmd/gopcomm/community.gop:15:1
return
}()
//line cmd/gopcomm/community.gop:16:1
y := yap.New(fsYap)
//line cmd/gopcomm/community.gop:18:1
y.GET("/p/:id", func(ctx *yap.Context) {
//line cmd/gopcomm/community.gop:19:1
ctx.YAP(200, "article", article{ID: ctx.Param("id")})
//line cmd/gopcomm/community_yap.gox:1
func (this *community_yap) MainEntry() {
//line cmd/gopcomm/community_yap.gox:1:1
this.Get("/p/:id", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:2:1
ctx.Yap__1("article", map[string]string{"id": ctx.Param("id")})
})
//line cmd/gopcomm/community_yap.gox:6:1
this.Get("/", func(ctx *yap.Context) {
//line cmd/gopcomm/community_yap.gox:7:1
ctx.Yap__1("home", map[string]interface {
}{})
})
//line cmd/gopcomm/community.gop:24:1
y.Run(":8080")
//line cmd/gopcomm/community_yap.gox:10:1
this.Run__1(":8080")
}
func main() {
yap.Gopt_App_Main(new(community_yap))
}
2 changes: 1 addition & 1 deletion cmd/gopcomm/yap/article.yap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<meta charset="utf-8"/>
</head>
<body>
Article {{.ID}}
Article {{.id}}
</body>
</html>
8 changes: 8 additions & 0 deletions cmd/gopcomm/yap/home.yap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
Go+ Community <a href="/p/123">written in Go+</a>
</body>
</html>
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ module github.com/goplus/community

go 1.18

require (
github.com/goplus/yap v0.3.0
github.com/qiniu/x v1.13.2
)
require github.com/goplus/yap v0.5.0 //gop:class
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
github.com/goplus/yap v0.3.0 h1:htp4eANRtBcaOAJuJNAVAtevQETJxKq4A+UV/v66fv0=
github.com/goplus/yap v0.3.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=
github.com/goplus/yap v0.5.0 h1:CU+QXeSNAcx72as7O2FC1NWCazKB7cf7dLyexmbf8y4=
github.com/goplus/yap v0.5.0/go.mod h1:VCbGlZo2lUgRWciTZwA5JEOuCUf8T2PhxZZ0HXqzgBk=

0 comments on commit cb36d7e

Please sign in to comment.