upload.bm.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
  2. // source: upload.proto
  3. /*
  4. Package v1 is a generated blademaster stub package.
  5. This code was generated with go-common/app/tool/bmgen/protoc-gen-bm v0.1.
  6. It is generated from these files:
  7. upload.proto
  8. */
  9. package v1
  10. import (
  11. "context"
  12. bm "go-common/library/net/http/blademaster"
  13. "go-common/library/net/http/blademaster/binding"
  14. )
  15. // to suppressed 'imported but not used warning'
  16. var _ *bm.Context
  17. var _ context.Context
  18. var _ binding.StructValidator
  19. var PathTokenNew = "/live.liveadmin.v1.Token/new"
  20. var PathUploadFile = "/live.liveadmin.v1.Upload/file"
  21. // ===============
  22. // Token Interface
  23. // ===============
  24. type TokenBMServer interface {
  25. // Request for a token for upload.
  26. // `method:"POST" internal:"true"`
  27. New(ctx context.Context, req *NewTokenReq) (resp *NewTokenResp, err error)
  28. }
  29. var v1TokenSvc TokenBMServer
  30. func tokenNew(c *bm.Context) {
  31. p := new(NewTokenReq)
  32. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  33. return
  34. }
  35. resp, err := v1TokenSvc.New(c, p)
  36. c.JSON(resp, err)
  37. }
  38. // RegisterV1TokenService Register the blademaster route with middleware map
  39. // midMap is the middleware map, the key is defined in proto
  40. func RegisterV1TokenService(e *bm.Engine, svc TokenBMServer, midMap map[string]bm.HandlerFunc) {
  41. v1TokenSvc = svc
  42. e.POST("/xlive/internal/live-admin/v1/token/new", tokenNew)
  43. }
  44. // RegisterTokenBMServer Register the blademaster route
  45. func RegisterTokenBMServer(e *bm.Engine, server TokenBMServer) {
  46. v1TokenSvc = server
  47. e.POST("/live.liveadmin.v1.Token/new", tokenNew)
  48. }
  49. // ================
  50. // Upload Interface
  51. // ================
  52. type UploadBMServer interface {
  53. // `method:"POST" content-type:"multipart/form-data" midware:"cors,guest"`
  54. File(ctx context.Context, req *UploadFileReq) (resp *UploadFileResp, err error)
  55. }
  56. var v1UploadSvc UploadBMServer
  57. func uploadFile(c *bm.Context) {
  58. p := new(UploadFileReq)
  59. if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
  60. return
  61. }
  62. resp, err := v1UploadSvc.File(c, p)
  63. c.JSON(resp, err)
  64. }
  65. // RegisterV1UploadService Register the blademaster route with middleware map
  66. // midMap is the middleware map, the key is defined in proto
  67. func RegisterV1UploadService(e *bm.Engine, svc UploadBMServer, midMap map[string]bm.HandlerFunc) {
  68. cors := midMap["cors"]
  69. guest := midMap["guest"]
  70. v1UploadSvc = svc
  71. e.POST("/xlive/live-admin/v1/upload/file", cors, guest, uploadFile)
  72. }
  73. // RegisterUploadBMServer Register the blademaster route
  74. func RegisterUploadBMServer(e *bm.Engine, server UploadBMServer) {
  75. v1UploadSvc = server
  76. e.POST("/live.liveadmin.v1.Upload/file", uploadFile)
  77. }