8000 fix: bug init app by ren0503 · Pull Request #7 · tinh-tinh/tinhtinh-cli · GitHub
[go: up one dir, main page]

Skip to content
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ bin

.idea/
.vscode/
*.iml
*.iml
coverage/
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: test-coverage

test-coverage:
go test -v ./... -covermode=count -coverpkg=./... -coverprofile coverage/coverage.out
go tool cover -html coverage/coverage.out -o coverage/coverage.html
12 changes: 6 additions & 6 deletions tpl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func main() {
server := core.CreateFactory(app.NewModule, "api")
server := core.CreateFactory(app.NewModule)

server.Listen(3000)
}
Expand Down Expand Up @@ -62,23 +62,23 @@ import "github.com/tinh-tinh/tinhtinh/core"
func NewController(module *core.DynamicModule) *core.DynamicController {
ctrl := module.NewController("{{ .ModName }}")

ctrl.Post("/", func(ctx core.Ctx) error {
ctrl.Post("", func(ctx core.Ctx) error {
return ctx.JSON(core.Map{"data": "ok"})
})

ctrl.Get("/", func(ctx core.Ctx) error {
ctrl.Get("", func(ctx core.Ctx) error {
return ctx.JSON(core.Map{"data": "ok"})
})

ctrl.Get("/{id}", func(ctx core.Ctx) error {
ctrl.Get("{id}", func(ctx core.Ctx) error {
return ctx.JSON(core.Map{"data": "ok"})
})

ctrl.Put("/{id}", func(ctx core.Ctx) error {
ctrl.Put("{id}", func(ctx core.Ctx) error {
return ctx.JSON(core.Map{"data": "ok"})
})

ctrl.Delete("/{id}", func(ctx core.Ctx) error {
ctrl.Delete("{id}", func(ctx core.Ctx) error {
return ctx.JSON(core.Map{"data": "ok"})
})

Expand Down
0