You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/examples/validate/api/example_http.pb.go

72 lines
2.1 KiB

// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
4 years ago
// protoc-gen-go-http v2.0.0
package v1
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
type ExampleServiceHTTPServer interface {
TestValidate(context.Context, *Request) (*Reply, error)
}
func RegisterExampleServiceHTTPServer(s *http.Server, srv ExampleServiceHTTPServer) {
r := s.Route("/")
r.POST("/v1/validate", _ExampleService_TestValidate0_HTTP_Handler(srv))
}
func _ExampleService_TestValidate0_HTTP_Handler(srv ExampleServiceHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in Request
if err := ctx.Bind(&in); err != nil {
return err
}
http.SetOperation(ctx, "/api.example.ExampleService/TestValidate")
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.TestValidate(ctx, req.(*Request))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*Reply)
return ctx.Result(200, reply)
}
}
type ExampleServiceHTTPClient interface {
TestValidate(ctx context.Context, req *Request, opts ...http.CallOption) (rsp *Reply, err error)
}
type ExampleServiceHTTPClientImpl struct {
cc *http.Client
}
func NewExampleServiceHTTPClient(client *http.Client) ExampleServiceHTTPClient {
return &ExampleServiceHTTPClientImpl{client}
}
func (c *ExampleServiceHTTPClientImpl) TestValidate(ctx context.Context, in *Request, opts ...http.CallOption) (*Reply, error) {
var out Reply
pattern := "/v1/validate"
path := binding.EncodeURL(pattern, in, false)
opts = append(opts, http.Operation("/api.example.ExampleService/TestValidate"))
opts = append(opts, http.PathTemplate(pattern))
err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
if err != nil {
return nil, err
}
return &out, err
}