go-common/app/admin/live/live-admin/api/http/v1/upload.bm.go
2019-04-22 18:49:16 +08:00

97 lines
2.7 KiB
Go

// Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
// source: upload.proto
/*
Package v1 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:
upload.proto
*/
package v1
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 PathTokenNew = "/live.liveadmin.v1.Token/new"
var PathUploadFile = "/live.liveadmin.v1.Upload/file"
// ===============
// Token Interface
// ===============
type TokenBMServer interface {
// Request for a token for upload.
// `method:"POST" internal:"true"`
New(ctx context.Context, req *NewTokenReq) (resp *NewTokenResp, err error)
}
var v1TokenSvc TokenBMServer
func tokenNew(c *bm.Context) {
p := new(NewTokenReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1TokenSvc.New(c, p)
c.JSON(resp, err)
}
// RegisterV1TokenService Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterV1TokenService(e *bm.Engine, svc TokenBMServer, midMap map[string]bm.HandlerFunc) {
v1TokenSvc = svc
e.POST("/xlive/internal/live-admin/v1/token/new", tokenNew)
}
// RegisterTokenBMServer Register the blademaster route
func RegisterTokenBMServer(e *bm.Engine, server TokenBMServer) {
v1TokenSvc = server
e.POST("/live.liveadmin.v1.Token/new", tokenNew)
}
// ================
// Upload Interface
// ================
type UploadBMServer interface {
// `method:"POST" content-type:"multipart/form-data" midware:"cors,guest"`
File(ctx context.Context, req *UploadFileReq) (resp *UploadFileResp, err error)
}
var v1UploadSvc UploadBMServer
func uploadFile(c *bm.Context) {
p := new(UploadFileReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1UploadSvc.File(c, p)
c.JSON(resp, err)
}
// RegisterV1UploadService Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterV1UploadService(e *bm.Engine, svc UploadBMServer, midMap map[string]bm.HandlerFunc) {
cors := midMap["cors"]
guest := midMap["guest"]
v1UploadSvc = svc
e.POST("/xlive/live-admin/v1/upload/file", cors, guest, uploadFile)
}
// RegisterUploadBMServer Register the blademaster route
func RegisterUploadBMServer(e *bm.Engine, server UploadBMServer) {
v1UploadSvc = server
e.POST("/live.liveadmin.v1.Upload/file", uploadFile)
}