-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_gors.go
40 lines (36 loc) · 1.11 KB
/
service_gors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Code generated by "gors -service Service"; DO NOT EDIT.
package demo
import (
gin "github.com/gin-gonic/gin"
gors "github.com/go-leo/gors"
http "net/http"
)
func ServiceRoutes(srv Service, opts ...gors.Option) []gors.Route {
options := gors.NewOptions(opts...)
return []gors.Route{
gors.NewRoute(http.MethodGet, "/api/v1/method/:id", _Service_Method_Handler(srv, options)),
}
}
func _Service_Method_Handler(srv Service, options *gors.Options) func(c *gin.Context) {
return func(c *gin.Context) {
var rpcMethodName = "/demo.Service/Method"
var ctx = gors.NewContext(c, rpcMethodName)
var req *MethodReq
var resp *MethodResp
var err error
req = new(MethodReq)
if err = gors.RequestBind(
ctx, req, options.Tag,
gors.UriBinding,
); err != nil {
gors.ErrorRender(ctx, err, options.ErrorHandler, options.ResponseWrapper)
return
}
resp, err = srv.Method(ctx, req)
if err != nil {
gors.ErrorRender(ctx, err, options.ErrorHandler, options.ResponseWrapper)
return
}
gors.ResponseRender(ctx, gors.StatusCode(ctx), resp, "application/json", gors.JSONRender, options.ResponseWrapper)
}
}