-
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
17 changed files
with
72 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
module github.com/alimy/mir/v2/examples | ||
module github.com/alimy/mir-example | ||
|
||
go 1.12 | ||
go 1.16 | ||
|
||
require ( | ||
github.com/alimy/mir/v2 v2.7.0-alpha | ||
github.com/gin-gonic/gin v1.6.3 | ||
github.com/alimy/mir/v2 v2.7.2 | ||
github.com/gin-gonic/gin v1.7.7 | ||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect | ||
) |
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 |
---|---|---|
@@ -1,20 +1,16 @@ | ||
// Copyright 2019 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/alimy/mir/v2/examples/servants" | ||
"github.com/alimy/mir-example/servants" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func main() { | ||
e := gin.New() | ||
e := gin.Default() | ||
|
||
// register servants to engine | ||
// register servants to gin | ||
servants.RegisterServants(e) | ||
|
||
// start servant service | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
// Copyright 2019 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
|
@@ -10,16 +6,16 @@ import ( | |
. "github.com/alimy/mir/v2/core" | ||
. "github.com/alimy/mir/v2/engine" | ||
|
||
_ "github.com/alimy/mir/v2/examples/mirc/routes" | ||
_ "github.com/alimy/mir/v2/examples/mirc/routes/v1" | ||
_ "github.com/alimy/mir/v2/examples/mirc/routes/v2" | ||
_ "github.com/alimy/mir-example/mirc/routes" | ||
_ "github.com/alimy/mir-example/mirc/routes/v1" | ||
_ "github.com/alimy/mir-example/mirc/routes/v2" | ||
) | ||
|
||
//go:generate go run main.go | ||
func main() { | ||
log.Println("generate code start") | ||
opts := Options{ | ||
RunMode(InSerialDebugMode), | ||
RunMode(InSerialMode), | ||
GeneratorName(GeneratorGin), | ||
SinkPath("auto"), | ||
} | ||
|
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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
// Copyright 2019 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package routes | ||
|
||
import ( | ||
|
@@ -13,7 +9,7 @@ func init() { | |
AddEntry(new(Site)) | ||
} | ||
|
||
// Site mir's struct tag define | ||
// Site site interface info | ||
type Site struct { | ||
Chain Chain `mir:"-"` | ||
Index Get `mir:"/index/"` | ||
|
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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
// Copyright 2019 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package v1 | ||
|
||
import ( | ||
|
@@ -13,7 +9,7 @@ func init() { | |
AddEntry(new(Site)) | ||
} | ||
|
||
// Site mir's struct tag define | ||
// Site site v1 interface info | ||
type Site struct { | ||
Chain Chain `mir:"-"` | ||
Group Group `mir:"v1"` | ||
|
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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
// Copyright 2019 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package v2 | ||
|
||
import ( | ||
|
@@ -13,7 +9,7 @@ func init() { | |
AddEntry(new(Site)) | ||
} | ||
|
||
// Site mir's struct tag define | ||
// Site site v2 interface info | ||
type Site struct { | ||
Group Group `mir:"v2"` | ||
Index Get `mir:"/index/"` | ||
|
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 |
---|---|---|
@@ -1,15 +1,11 @@ | ||
// Copyright 2021 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package servants | ||
|
||
import ( | ||
"github.com/alimy/mir/v2/examples/mirc/auto/api" | ||
"github.com/alimy/mir-example/mirc/auto/api" | ||
"github.com/gin-gonic/gin" | ||
|
||
v1 "github.com/alimy/mir/v2/examples/mirc/auto/api/v1" | ||
v2 "github.com/alimy/mir/v2/examples/mirc/auto/api/v2" | ||
v1 "github.com/alimy/mir-example/mirc/auto/api/v1" | ||
v2 "github.com/alimy/mir-example/mirc/auto/api/v2" | ||
) | ||
|
||
// RegisterServants register all the servants to gin.Engine | ||
|
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 |
---|---|---|
@@ -1,32 +1,11 @@ | ||
// Copyright 2019 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package servants | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/alimy/mir/v2/examples/mirc/auto/api" | ||
"github.com/gin-gonic/gin" | ||
) | ||
import "github.com/alimy/mir-example/mirc/auto/api" | ||
|
||
type emptySiteWithNoGroup struct { | ||
type siteSrv struct { | ||
api.UnimplementedSiteServant | ||
} | ||
|
||
func (emptySiteWithNoGroup) Chain() gin.HandlersChain { | ||
return gin.HandlersChain{gin.Logger()} | ||
} | ||
|
||
func (emptySiteWithNoGroup) Index(c *gin.Context) { | ||
c.String(http.StatusOK, "get index data") | ||
} | ||
|
||
func (emptySiteWithNoGroup) Articles(c *gin.Context) { | ||
c.String(http.StatusOK, "get articles data") | ||
} | ||
|
||
func newSiteSrv() api.Site { | ||
return &emptySiteWithNoGroup{} | ||
return &siteSrv{} | ||
} |
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 |
---|---|---|
@@ -1,29 +1,13 @@ | ||
// Copyright 2019 Michael Li <[email protected]>. All rights reserved. | ||
// Use of this source code is governed by Apache License 2.0 that | ||
// can be found in the LICENSE file. | ||
|
||
package servants | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
|
||
api "github.com/alimy/mir/v2/examples/mirc/auto/api/v1" | ||
v1 "github.com/alimy/mir-example/mirc/auto/api/v1" | ||
) | ||
|
||
type emptySiteV1 struct { | ||
api.UnimplementedSiteServant | ||
} | ||
|
||
func (*emptySiteV1) Index(c *gin.Context) { | ||
c.String(http.StatusOK, "get index data (v1)") | ||
} | ||
|
||
func (*emptySiteV1) Articles(c *gin.Context) { | ||
c.String(http.StatusOK, "get articles data (v1)") | ||
type siteV1Srv struct { | ||
v1.UnimplementedSiteServant | ||
} | ||
|
||
func newSiteV1Srv() api.Site { | ||
return &emptySiteV1{} | ||
func newSiteV1Srv() v1.Site { | ||
return &siteV1Srv{} | ||
} |
Oops, something went wrong.