From 62ab2a5d7e4516b98e571d07f7f40a07966ace63 Mon Sep 17 00:00:00 2001 From: alimy Date: Sun, 31 Jan 2021 16:37:41 +0800 Subject: [PATCH] update examples --- examples/.gitignore | 19 ++++++++ examples/Makefile | 9 +++- examples/go.mod | 4 +- examples/go.sum | 52 +++++++++++++--------- examples/main.go | 19 +------- examples/mirc/{gen => auto}/api/site.go | 20 ++++++++- examples/mirc/{gen => auto}/api/v1/site.go | 20 ++++++++- examples/mirc/auto/api/v2/site.go | 41 +++++++++++++++++ examples/mirc/gen/api/v2/site.go | 23 ---------- examples/mirc/main.go | 2 +- examples/servants/servants.go | 20 +++++++++ examples/servants/site.go | 19 ++++---- examples/servants/site_v1.go | 19 ++++---- examples/servants/site_v2.go | 21 +++++---- 14 files changed, 195 insertions(+), 93 deletions(-) rename examples/mirc/{gen => auto}/api/site.go (51%) rename examples/mirc/{gen => auto}/api/v1/site.go (51%) create mode 100644 examples/mirc/auto/api/v2/site.go delete mode 100644 examples/mirc/gen/api/v2/site.go create mode 100644 examples/servants/servants.go diff --git a/examples/.gitignore b/examples/.gitignore index e41304d..b280a60 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1 +1,20 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +coverage.out +count.out +test +profile.out +tmp.out + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + /mir-examples diff --git a/examples/Makefile b/examples/Makefile index 4cb822b..1218024 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,17 +1,24 @@ GOFMT ?= gofmt -s -w GOFILES := $(shell find . -name "*.go" -type f) +TARGET := mir-examples + .PHONY: default default: run .PHONY: build build: fmt - go build -o mir-examples main.go + go build -o ${TARGET} main.go .PHONY: build run: fmt go run main.go +.PHONY: mod-tidy +mod-tidy: + @go mod download + @go mod tidy + .PHONY: generate generate: @go generate mirc/main.go diff --git a/examples/go.mod b/examples/go.mod index c350499..63463da 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -3,6 +3,6 @@ module github.com/alimy/mir/v2/examples go 1.12 require ( - github.com/alimy/mir/v2 v2.4.0 - github.com/gin-gonic/gin v1.5.0 + github.com/alimy/mir/v2 v2.7.0-alpha + github.com/gin-gonic/gin v1.6.3 ) diff --git a/examples/go.sum b/examples/go.sum index 8a6908b..3cf79f1 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -1,37 +1,49 @@ -github.com/alimy/mir/v2 v2.4.0 h1:I3qsHvR8vEPhrfGne+uoZhhAE/OAGFef84NWXB33bBI= -github.com/alimy/mir/v2 v2.4.0/go.mod h1:AkAOYbPbTxjp8DsUBTERZdXo+7jcSLEvKhLW+Zp9MZ8= +github.com/alimy/mir/v2 v2.7.0-alpha h1:PCuWtXA7d4sI0o212wjfibwnRKrDWOOOBeOWVGJICoo= +github.com/alimy/mir/v2 v2.7.0-alpha/go.mod h1:lsJwZ58471a9/pztfiBW6+rs3rRqry2yZfr3oFxHAJA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.5.0 h1:fi+bqFAx/oLK54somfCtEZs9HeH1LHVoEPUgARpTqyc= -github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= -github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotfhkmOqEc= -github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= -github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= -github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8= -github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= -github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v9 v9.29.1 h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvRQyEAKbw1xc= -gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/examples/main.go b/examples/main.go index 699d1a6..17eac00 100644 --- a/examples/main.go +++ b/examples/main.go @@ -7,33 +7,18 @@ package main import ( "log" - "github.com/gin-gonic/gin" - - "github.com/alimy/mir/v2/examples/mirc/gen/api" - "github.com/alimy/mir/v2/examples/mirc/gen/api/v1" - "github.com/alimy/mir/v2/examples/mirc/gen/api/v2" "github.com/alimy/mir/v2/examples/servants" + "github.com/gin-gonic/gin" ) func main() { e := gin.New() // register servants to engine - registerServants(e) + servants.RegisterServants(e) // start servant service if err := e.Run(); err != nil { log.Fatal(err) } } - -func registerServants(e *gin.Engine) { - // register default group routes - api.RegisterSiteServant(e, servants.EmptySiteWithNoGroup{}) - - // register routes for group v1 - v1.RegisterSiteServant(e, servants.EmptySiteV1{}) - - // register routes for group v2 - v2.RegisterSiteServant(e, servants.EmptySiteV2{}) -} diff --git a/examples/mirc/gen/api/site.go b/examples/mirc/auto/api/site.go similarity index 51% rename from examples/mirc/gen/api/site.go rename to examples/mirc/auto/api/site.go index 0d2750d..d67608d 100644 --- a/examples/mirc/gen/api/site.go +++ b/examples/mirc/auto/api/site.go @@ -3,7 +3,9 @@ package api import ( - "github.com/gin-gonic/gin" + "net/http" + + gin "github.com/gin-gonic/gin" ) type Site interface { @@ -25,3 +27,19 @@ func RegisterSiteServant(e *gin.Engine, s Site) { router.Handle("GET", "/index/", s.Index) router.Handle("GET", "/articles/:category/", s.Articles) } + +// UnimplementedSiteServant can be embedded to have forward compatible implementations. +type UnimplementedSiteServant struct { +} + +func (*UnimplementedSiteServant) Chain() gin.HandlersChain { + return nil +} + +func (*UnimplementedSiteServant) Index(c *gin.Context) { + c.String(http.StatusNotImplemented, "method Index not implemented") +} + +func (*UnimplementedSiteServant) Articles(c *gin.Context) { + c.String(http.StatusNotImplemented, "method Articles not implemented") +} diff --git a/examples/mirc/gen/api/v1/site.go b/examples/mirc/auto/api/v1/site.go similarity index 51% rename from examples/mirc/gen/api/v1/site.go rename to examples/mirc/auto/api/v1/site.go index 0b21fac..cee876c 100644 --- a/examples/mirc/gen/api/v1/site.go +++ b/examples/mirc/auto/api/v1/site.go @@ -3,7 +3,9 @@ package v1 import ( - "github.com/gin-gonic/gin" + "net/http" + + gin "github.com/gin-gonic/gin" ) type Site interface { @@ -25,3 +27,19 @@ func RegisterSiteServant(e *gin.Engine, s Site) { router.Handle("GET", "/index/", s.Index) router.Handle("GET", "/articles/:category/", s.Articles) } + +// UnimplementedSiteServant can be embedded to have forward compatible implementations. +type UnimplementedSiteServant struct { +} + +func (*UnimplementedSiteServant) Chain() gin.HandlersChain { + return nil +} + +func (*UnimplementedSiteServant) Index(c *gin.Context) { + c.String(http.StatusNotImplemented, "method Index not implemented") +} + +func (*UnimplementedSiteServant) Articles(c *gin.Context) { + c.String(http.StatusNotImplemented, "method Articles not implemented") +} diff --git a/examples/mirc/auto/api/v2/site.go b/examples/mirc/auto/api/v2/site.go new file mode 100644 index 0000000..4fcffbb --- /dev/null +++ b/examples/mirc/auto/api/v2/site.go @@ -0,0 +1,41 @@ +// Code generated by go-mir. DO NOT EDIT. + +package v2 + +import ( + "net/http" + + gin "github.com/gin-gonic/gin" +) + +type Site interface { + Index(*gin.Context) + Articles(*gin.Context) + Category(*gin.Context) +} + +// RegisterSiteServant register Site servant to gin +func RegisterSiteServant(e *gin.Engine, s Site) { + router := e.Group("v2") + + // register routes info to router + router.Handle("GET", "/index/", s.Index) + router.Handle("GET", "/articles/:category/", s.Articles) + router.Handle("GET", "/category/", s.Category) +} + +// UnimplementedSiteServant can be embedded to have forward compatible implementations. +type UnimplementedSiteServant struct { +} + +func (*UnimplementedSiteServant) Index(c *gin.Context) { + c.String(http.StatusNotImplemented, "method Index not implemented") +} + +func (*UnimplementedSiteServant) Articles(c *gin.Context) { + c.String(http.StatusNotImplemented, "method Articles not implemented") +} + +func (*UnimplementedSiteServant) Category(c *gin.Context) { + c.String(http.StatusNotImplemented, "method Category not implemented") +} diff --git a/examples/mirc/gen/api/v2/site.go b/examples/mirc/gen/api/v2/site.go deleted file mode 100644 index 77f8d90..0000000 --- a/examples/mirc/gen/api/v2/site.go +++ /dev/null @@ -1,23 +0,0 @@ -// Code generated by go-mir. DO NOT EDIT. - -package v2 - -import ( - "github.com/gin-gonic/gin" -) - -type Site interface { - Index(*gin.Context) - Articles(*gin.Context) - Category(*gin.Context) -} - -// RegisterSiteServant register Site servant to gin -func RegisterSiteServant(e *gin.Engine, s Site) { - router := e.Group("v2") - - // register routes info to router - router.Handle("GET", "/index/", s.Index) - router.Handle("GET", "/articles/:category/", s.Articles) - router.Handle("GET", "/category/", s.Category) -} diff --git a/examples/mirc/main.go b/examples/mirc/main.go index 668829d..b282693 100644 --- a/examples/mirc/main.go +++ b/examples/mirc/main.go @@ -21,7 +21,7 @@ func main() { opts := Options{ RunMode(InSerialDebugMode), GeneratorName(GeneratorGin), - SinkPath("./gen"), + SinkPath("auto"), } if err := Generate(opts); err != nil { log.Fatal(err) diff --git a/examples/servants/servants.go b/examples/servants/servants.go new file mode 100644 index 0000000..f675917 --- /dev/null +++ b/examples/servants/servants.go @@ -0,0 +1,20 @@ +// Copyright 2021 Michael Li . 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/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" +) + +// RegisterServants register all the servants to gin.Engine +func RegisterServants(e *gin.Engine) { + api.RegisterSiteServant(e, newSiteSrv()) + v1.RegisterSiteServant(e, newSiteV1Srv()) + v2.RegisterSiteServant(e, newSiteV2Srv()) +} diff --git a/examples/servants/site.go b/examples/servants/site.go index 210648c..91ae68a 100644 --- a/examples/servants/site.go +++ b/examples/servants/site.go @@ -7,23 +7,26 @@ package servants import ( "net/http" - "github.com/alimy/mir/v2/examples/mirc/gen/api" + "github.com/alimy/mir/v2/examples/mirc/auto/api" "github.com/gin-gonic/gin" ) -var _ api.Site = EmptySiteWithNoGroup{} - -// EmptySiteWithNoGroup implement api.Site interface -type EmptySiteWithNoGroup struct{} +type emptySiteWithNoGroup struct { + api.UnimplementedSiteServant +} -func (EmptySiteWithNoGroup) Chain() gin.HandlersChain { +func (emptySiteWithNoGroup) Chain() gin.HandlersChain { return gin.HandlersChain{gin.Logger()} } -func (EmptySiteWithNoGroup) Index(c *gin.Context) { +func (emptySiteWithNoGroup) Index(c *gin.Context) { c.String(http.StatusOK, "get index data") } -func (EmptySiteWithNoGroup) Articles(c *gin.Context) { +func (emptySiteWithNoGroup) Articles(c *gin.Context) { c.String(http.StatusOK, "get articles data") } + +func newSiteSrv() api.Site { + return &emptySiteWithNoGroup{} +} diff --git a/examples/servants/site_v1.go b/examples/servants/site_v1.go index 605a762..4ce0ee8 100644 --- a/examples/servants/site_v1.go +++ b/examples/servants/site_v1.go @@ -9,22 +9,21 @@ import ( "github.com/gin-gonic/gin" - api "github.com/alimy/mir/v2/examples/mirc/gen/api/v1" + api "github.com/alimy/mir/v2/examples/mirc/auto/api/v1" ) -var _ api.Site = EmptySiteV1{} - -// EmptySiteV1 implement api.Site interface -type EmptySiteV1 struct{} - -func (EmptySiteV1) Chain() gin.HandlersChain { - return nil +type emptySiteV1 struct { + api.UnimplementedSiteServant } -func (EmptySiteV1) Index(c *gin.Context) { +func (*emptySiteV1) Index(c *gin.Context) { c.String(http.StatusOK, "get index data (v1)") } -func (EmptySiteV1) Articles(c *gin.Context) { +func (*emptySiteV1) Articles(c *gin.Context) { c.String(http.StatusOK, "get articles data (v1)") } + +func newSiteV1Srv() api.Site { + return &emptySiteV1{} +} diff --git a/examples/servants/site_v2.go b/examples/servants/site_v2.go index bffafcf..7aa3e15 100644 --- a/examples/servants/site_v2.go +++ b/examples/servants/site_v2.go @@ -9,26 +9,29 @@ import ( "github.com/gin-gonic/gin" - api "github.com/alimy/mir/v2/examples/mirc/gen/api/v2" + api "github.com/alimy/mir/v2/examples/mirc/auto/api/v2" ) -var _ api.Site = EmptySiteV2{} - -// EmptySiteV2 implement api.Site interface -type EmptySiteV2 struct{} +type emptySiteV2 struct { + api.UnimplementedSiteServant +} -func (EmptySiteV2) Chain() gin.HandlersChain { +func (*emptySiteV2) Chain() gin.HandlersChain { return gin.HandlersChain{gin.Logger()} } -func (EmptySiteV2) Index(c *gin.Context) { +func (*emptySiteV2) Index(c *gin.Context) { c.String(http.StatusOK, "get index data (v2)") } -func (EmptySiteV2) Articles(c *gin.Context) { +func (*emptySiteV2) Articles(c *gin.Context) { c.String(http.StatusOK, "get articles data (v2)") } -func (EmptySiteV2) Category(c *gin.Context) { +func (*emptySiteV2) Category(c *gin.Context) { c.String(http.StatusOK, "get Category data (v2)") } + +func newSiteV2Srv() api.Site { + return &emptySiteV2{} +}