-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
381 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Code generated by go-mir. DO NOT EDIT. | ||
|
||
package {{ .PkgName }} | ||
|
||
import ( | ||
"github.com/gofiber/fiber" | ||
) | ||
|
||
{{if notEmptyStr .Comment }}// {{.Comment}}{{end}} | ||
type {{.TypeName}} interface { | ||
{{if notEmptyStr .Chain }}// Chain provide handlers chain for fiber | ||
{{.Chain}}() []func(*Ctx) | ||
{{end}} | ||
{{range .Fields}}{{if notEmptyStr .Comment }} // {{.Comment}} | ||
{{.MethodName}}(c *fiber.Ctx){{else}} {{.MethodName}}(c *fiber.Ctx){{end}} | ||
{{end}} | ||
} | ||
|
||
// Register{{.TypeName}}Servant register {{.TypeName}} servant to fiber | ||
func Register{{.TypeName}}Servant(app *fiber.App, s {{.TypeName}}) { | ||
{{if notEmptyStr .Group }} router := app.Group("{{.Group}}"){{else}} router := app{{end}} | ||
{{if notEmptyStr .Chain }} // use chain for router | ||
middlewares := s.{{.Chain}}() | ||
router.Use(middlewares...) | ||
{{end}} | ||
// register routes info to router | ||
{{range .Fields}}{{if eq .HttpMethod "GET" }} router.Get("{{.Path}}", s.{{.MethodName}}){{else if eq .HttpMethod "POST"}} router.Post("{{.Path}}", s.{{.MethodName}}){{else if eq .HttpMethod "PUT"}} router.Put("{{.Path}}", s.{{.MethodName}}){{else if eq .HttpMethod "DELETE"}} router.Delete("{{.Path}}", s.{{.MethodName}}){{else if eq .HttpMethod "HEAD"}} router.Head("{{.Path}}", s.{{.MethodName}}){{else if eq .HttpMethod "OPTIONS"}} router.Options("{{.Path}}", s.{{.MethodName}}){{else if eq .HttpMethod "TRACE"}} router.Trace("{{.Path}}", s.{{.MethodName}}){{else if eq .HttpMethod "PATCH"}} router.Patch("{{.Path}}", s.{{.MethodName}}){{else if eq .HttpMethod "CONNECT"}} router.Connect("{{.Path}}", s.{{.MethodName}}){{else if eq .HttpMethod "ANY" }} router.All("{{.Path}}", s.{{.MethodName}}){{end}} | ||
{{end}}} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
/macaron | ||
/echo | ||
/iris | ||
/fiber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module {{ .PkgName }} | ||
|
||
go 1.12 | ||
|
||
require ( | ||
github.com/alimy/mir/v2 v2.4.0 | ||
github.com/gofiber/fiber v1.8.431 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/gofiber/fiber" | ||
) | ||
|
||
func main() { | ||
app := fiber.New() | ||
|
||
// register servants to fiber | ||
registerServants(app) | ||
|
||
// start servant service | ||
if err := app.Listen(3000); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func registerServants(app *fiber.App) { | ||
// TODO: register routes to app | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/alimy/mir/v2/core" | ||
"github.com/alimy/mir/v2/engine" | ||
|
||
_ "{{ .PkgName }}/mirc/routes" | ||
_ "{{ .PkgName }}/mirc/routes/v1" | ||
_ "{{ .PkgName }}/mirc/routes/v2" | ||
) | ||
|
||
//go:generate go run main.go | ||
func main() { | ||
log.Println("generate code start") | ||
opts := core.Options{ | ||
core.RunMode(core.InSerialMode), | ||
core.GeneratorName(core.GeneratorFiber), | ||
core.NoneQuery(true), | ||
core.SinkPath("./gen"), | ||
} | ||
if err := engine.Generate(opts); err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Println("generate code finish") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package routes | ||
|
||
import ( | ||
"github.com/alimy/mir/v2" | ||
"github.com/alimy/mir/v2/engine" | ||
) | ||
|
||
func init() { | ||
engine.AddEntry(new(Site)) | ||
} | ||
|
||
// Site site interface info | ||
type Site struct { | ||
Chain mir.Chain `mir:"-"` | ||
Index mir.Get `mir:"/index/"` | ||
Articles mir.Get `mir:"/articles/:category/"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package v1 | ||
|
||
import ( | ||
"github.com/alimy/mir/v2" | ||
"github.com/alimy/mir/v2/engine" | ||
) | ||
|
||
func init() { | ||
engine.AddEntry(new(Site)) | ||
} | ||
|
||
// Site site v1 interface info | ||
type Site struct { | ||
Chain mir.Chain `mir:"-"` | ||
Group mir.Group `mir:"v1"` | ||
Index mir.Get `mir:"/index/"` | ||
Articles mir.Get `mir:"/articles/:category/"` | ||
} |
Oops, something went wrong.