mse-go-demo/multiframe/B/proto/c_api/helloworld_http.pb.go (78 lines of code) (raw):
// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.8.0
// - protoc v3.15.5
// source: api/helloworld/c_api/helloworld.proto
package c_api
import (
context "context"
http "github.com/go-kratos/kratos/v2/transport/http"
binding "github.com/go-kratos/kratos/v2/transport/http/binding"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the kratos package it is being compiled against.
var _ = new(context.Context)
var _ = binding.EncodeURL
const _ = http.SupportPackageIsVersion1
const OperationCGreeterCSayHello = "/helloworld.CGreeter/CSayHello"
type CGreeterHTTPServer interface {
// CSayHello Sends a greeting
CSayHello(context.Context, *CHelloRequest) (*CHelloReply, error)
}
func RegisterCGreeterHTTPServer(s *http.Server, srv CGreeterHTTPServer) {
r := s.Route("/")
r.POST("/greet2c", _CGreeter_CSayHello0_HTTP_Handler(srv))
r.GET("/greet1c", _CGreeter_CSayHello1_HTTP_Handler(srv))
}
func _CGreeter_CSayHello0_HTTP_Handler(srv CGreeterHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in CHelloRequest
if err := ctx.Bind(&in); err != nil {
return err
}
if err := ctx.BindQuery(&in); err != nil {
return err
}
http.SetOperation(ctx, OperationCGreeterCSayHello)
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.CSayHello(ctx, req.(*CHelloRequest))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*CHelloReply)
return ctx.Result(200, reply)
}
}
func _CGreeter_CSayHello1_HTTP_Handler(srv CGreeterHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in CHelloRequest
if err := ctx.BindQuery(&in); err != nil {
return err
}
http.SetOperation(ctx, OperationCGreeterCSayHello)
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.CSayHello(ctx, req.(*CHelloRequest))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*CHelloReply)
return ctx.Result(200, reply)
}
}
type CGreeterHTTPClient interface {
CSayHello(ctx context.Context, req *CHelloRequest, opts ...http.CallOption) (rsp *CHelloReply, err error)
}
type CGreeterHTTPClientImpl struct {
cc *http.Client
}
func NewCGreeterHTTPClient(client *http.Client) CGreeterHTTPClient {
return &CGreeterHTTPClientImpl{client}
}
func (c *CGreeterHTTPClientImpl) CSayHello(ctx context.Context, in *CHelloRequest, opts ...http.CallOption) (*CHelloReply, error) {
var out CHelloReply
pattern := "/greet1c"
path := binding.EncodeURL(pattern, in, true)
opts = append(opts, http.Operation(OperationCGreeterCSayHello))
opts = append(opts, http.PathTemplate(pattern))
err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...)
if err != nil {
return nil, err
}
return &out, nil
}