go-common/app/interface/live/live-demo/api/http/v2/service.bm.go

176 lines
5.2 KiB
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
// Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
// source: service.proto
/*
Package v2 is a generated blademaster stub package.
This code was generated with go-common/app/tool/bmgen/protoc-gen-bm v0.1.
It is generated from these files:
service.proto
*/
package v2
import (
"context"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/http/blademaster/binding"
)
// to suppressed 'imported but not used warning'
var _ *bm.Context
var _ context.Context
var _ binding.StructValidator
var PathFooUnameByUid = "/xlive/demo/v1/foo/uname_by_uid_custom_route"
var PathFooGetInfo = "/live.livedemo.v2.Foo/get_info"
var PathFooUnameByUid3 = "/live.livedemo.v2.Foo/uname_by_uid3"
var PathFooUnameByUid4 = "/live.livedemo.v2.Foo/uname_by_uid4"
var PathFooGetDynamic = "/live.livedemo.v2.Foo/get_dynamic"
var PathFooNointerface = "/live.livedemo.v2.Foo/nointerface"
var PathFooJsonReq = "/live.livedemo.v2.Foo/json_req"
var PathFoo2Hello = "/live.livedemo.v2.Foo2/hello"
// =============
// Foo Interface
// =============
// Foo 相关服务
type FooBMServer interface {
// 根据uid得到uname
// `method:"post" midware:"auth,verify"`
//
// 这是详细说明
UnameByUid(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
// 获取房间信息
// `midware:"guest"`
GetInfo(ctx context.Context, req *GetInfoReq) (resp *GetInfoResp, err error)
// 根据uid得到uname v3
UnameByUid3(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
// test comment
// `internal:"true"`
UnameByUid4(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
// `dynamic_resp:"true"`
GetDynamic(ctx context.Context, req *Bar1Req) (resp interface{}, err error)
// `method:"POST"`
JsonReq(ctx context.Context, req *JsonReq) (resp *JsonResp, err error)
}
var v2FooSvc FooBMServer
func fooUnameByUid(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v2FooSvc.UnameByUid(c, p)
c.JSON(resp, err)
}
func fooGetInfo(c *bm.Context) {
p := new(GetInfoReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v2FooSvc.GetInfo(c, p)
c.JSON(resp, err)
}
func fooUnameByUid3(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v2FooSvc.UnameByUid3(c, p)
c.JSON(resp, err)
}
func fooUnameByUid4(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v2FooSvc.UnameByUid4(c, p)
c.JSON(resp, err)
}
func fooGetDynamic(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v2FooSvc.GetDynamic(c, p)
c.JSON(resp, err)
}
func fooJsonReq(c *bm.Context) {
p := new(JsonReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v2FooSvc.JsonReq(c, p)
c.JSON(resp, err)
}
// RegisterV2FooService Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterV2FooService(e *bm.Engine, svc FooBMServer, midMap map[string]bm.HandlerFunc) {
auth := midMap["auth"]
guest := midMap["guest"]
verify := midMap["verify"]
v2FooSvc = svc
e.GET("/xlive/demo/v1/foo/uname_by_uid_custom_route", auth, verify, fooUnameByUid)
e.GET("/xlive/live-demo/v2/foo/get_info", guest, fooGetInfo)
e.GET("/xlive/live-demo/v2/foo/uname_by_uid3", fooUnameByUid3)
e.GET("/xlive/internal/live-demo/v2/foo/uname_by_uid4", fooUnameByUid4)
e.GET("/xlive/live-demo/v2/foo/get_dynamic", fooGetDynamic)
e.POST("/xlive/live-demo/v2/foo/json_req", fooJsonReq)
}
// RegisterFooBMServer Register the blademaster route
func RegisterFooBMServer(e *bm.Engine, server FooBMServer) {
e.GET("/xlive/demo/v1/foo/uname_by_uid_custom_route", fooUnameByUid)
e.GET("/live.livedemo.v2.Foo/get_info", fooGetInfo)
e.GET("/live.livedemo.v2.Foo/uname_by_uid3", fooUnameByUid3)
e.GET("/live.livedemo.v2.Foo/uname_by_uid4", fooUnameByUid4)
e.GET("/live.livedemo.v2.Foo/get_dynamic", fooGetDynamic)
e.POST("/live.livedemo.v2.Foo/json_req", fooJsonReq)
}
// ==============
// Foo2 Interface
// ==============
type Foo2BMServer interface {
Hello(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
}
var v2Foo2Svc Foo2BMServer
func foo2Hello(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v2Foo2Svc.Hello(c, p)
c.JSON(resp, err)
}
// RegisterV2Foo2Service Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterV2Foo2Service(e *bm.Engine, svc Foo2BMServer, midMap map[string]bm.HandlerFunc) {
v2Foo2Svc = svc
e.GET("/xlive/live-demo/v2/foo2/hello", foo2Hello)
}
// RegisterFoo2BMServer Register the blademaster route
func RegisterFoo2BMServer(e *bm.Engine, server Foo2BMServer) {
e.GET("/live.livedemo.v2.Foo2/hello", foo2Hello)
}