// Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
// source: service.proto

/*
Package livedemo 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 livedemo

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 = "/live.livedemo.Foo/uname_by_uid"
var PathFooGetInfo = "/live.livedemo.Foo/get_info"
var PathFooUnameByUid3 = "/live.livedemo.Foo/uname_by_uid3"
var PathFooUnameByUid4 = "/live.livedemo.Foo/uname_by_uid4"
var PathFooGetDynamic = "/live.livedemo.Foo/get_dynamic"
var PathFooNointerface = "/live.livedemo.Foo/nointerface"

var PathFoo2Hello = "/live.livedemo.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)
}

var FooSvc 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 := FooSvc.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 := FooSvc.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 := FooSvc.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 := FooSvc.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 := FooSvc.GetDynamic(c, p)
	c.JSON(resp, err)
}

// RegisterFooService Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterFooService(e *bm.Engine, svc FooBMServer, midMap map[string]bm.HandlerFunc) {
	auth := midMap["auth"]
	guest := midMap["guest"]
	verify := midMap["verify"]
	FooSvc = svc
	e.POST("/xlive/live-demo/foo/uname_by_uid", auth, verify, fooUnameByUid)
	e.GET("/xlive/live-demo/foo/get_info", guest, fooGetInfo)
	e.GET("/xlive/live-demo/foo/uname_by_uid3", fooUnameByUid3)
	e.GET("/xlive/internal/live-demo/foo/uname_by_uid4", fooUnameByUid4)
	e.GET("/xlive/live-demo/foo/get_dynamic", fooGetDynamic)
}

// RegisterFooBMServer Register the blademaster route
func RegisterFooBMServer(e *bm.Engine, server FooBMServer) {
	e.POST("/live.livedemo.Foo/uname_by_uid", fooUnameByUid)
	e.GET("/live.livedemo.Foo/get_info", fooGetInfo)
	e.GET("/live.livedemo.Foo/uname_by_uid3", fooUnameByUid3)
	e.GET("/live.livedemo.Foo/uname_by_uid4", fooUnameByUid4)
	e.GET("/live.livedemo.Foo/get_dynamic", fooGetDynamic)
}

// ==============
// Foo2 Interface
// ==============

type Foo2BMServer interface {
	Hello(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
}

var Foo2Svc 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 := Foo2Svc.Hello(c, p)
	c.JSON(resp, err)
}

// RegisterFoo2Service Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterFoo2Service(e *bm.Engine, svc Foo2BMServer, midMap map[string]bm.HandlerFunc) {
	Foo2Svc = svc
	e.GET("/xlive/live-demo/foo2/hello", foo2Hello)
}

// RegisterFoo2BMServer Register the blademaster route
func RegisterFoo2BMServer(e *bm.Engine, server Foo2BMServer) {
	e.GET("/live.livedemo.Foo2/hello", foo2Hello)
}
