github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/form/api/proto/api.micro.go (about) 1 // Code generated by protoc-gen-micro. DO NOT EDIT. 2 // source: proto/api.proto 3 4 package api 5 6 import ( 7 fmt "fmt" 8 proto "github.com/golang/protobuf/proto" 9 proto1 "github.com/micro/go-micro/v2/api/proto" 10 math "math" 11 ) 12 13 import ( 14 context "context" 15 client "github.com/micro/go-micro/v2/client" 16 server "github.com/micro/go-micro/v2/server" 17 ) 18 19 // Reference imports to suppress errors if they are not otherwise used. 20 var _ = proto.Marshal 21 var _ = fmt.Errorf 22 var _ = math.Inf 23 24 // This is a compile-time assertion to ensure that this generated file 25 // is compatible with the proto package it is being compiled against. 26 // A compilation error at this line likely means your copy of the 27 // proto package needs to be updated. 28 const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package 29 30 // Reference imports to suppress errors if they are not otherwise used. 31 var _ context.Context 32 var _ client.Option 33 var _ server.Option 34 35 // Client API for Form service 36 37 type FormService interface { 38 // regular form 39 Submit(ctx context.Context, in *proto1.Request, opts ...client.CallOption) (*proto1.Response, error) 40 // multipart form 41 Multipart(ctx context.Context, in *proto1.Request, opts ...client.CallOption) (*proto1.Response, error) 42 } 43 44 type formService struct { 45 c client.Client 46 name string 47 } 48 49 func NewFormService(name string, c client.Client) FormService { 50 if c == nil { 51 c = client.NewClient() 52 } 53 if len(name) == 0 { 54 name = "form" 55 } 56 return &formService{ 57 c: c, 58 name: name, 59 } 60 } 61 62 func (c *formService) Submit(ctx context.Context, in *proto1.Request, opts ...client.CallOption) (*proto1.Response, error) { 63 req := c.c.NewRequest(c.name, "Form.Submit", in) 64 out := new(proto1.Response) 65 err := c.c.Call(ctx, req, out, opts...) 66 if err != nil { 67 return nil, err 68 } 69 return out, nil 70 } 71 72 func (c *formService) Multipart(ctx context.Context, in *proto1.Request, opts ...client.CallOption) (*proto1.Response, error) { 73 req := c.c.NewRequest(c.name, "Form.Multipart", in) 74 out := new(proto1.Response) 75 err := c.c.Call(ctx, req, out, opts...) 76 if err != nil { 77 return nil, err 78 } 79 return out, nil 80 } 81 82 // Server API for Form service 83 84 type FormHandler interface { 85 // regular form 86 Submit(context.Context, *proto1.Request, *proto1.Response) error 87 // multipart form 88 Multipart(context.Context, *proto1.Request, *proto1.Response) error 89 } 90 91 func RegisterFormHandler(s server.Server, hdlr FormHandler, opts ...server.HandlerOption) error { 92 type form interface { 93 Submit(ctx context.Context, in *proto1.Request, out *proto1.Response) error 94 Multipart(ctx context.Context, in *proto1.Request, out *proto1.Response) error 95 } 96 type Form struct { 97 form 98 } 99 h := &formHandler{hdlr} 100 return s.Handle(s.NewHandler(&Form{h}, opts...)) 101 } 102 103 type formHandler struct { 104 FormHandler 105 } 106 107 func (h *formHandler) Submit(ctx context.Context, in *proto1.Request, out *proto1.Response) error { 108 return h.FormHandler.Submit(ctx, in, out) 109 } 110 111 func (h *formHandler) Multipart(ctx context.Context, in *proto1.Request, out *proto1.Response) error { 112 return h.FormHandler.Multipart(ctx, in, out) 113 }