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.
113 lines
3.3 KiB
113 lines
3.3 KiB
// Code generated by protoc-gen-go-http. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-http v2.7.0
|
|
// - protoc v3.21.12
|
|
// source: greeter.proto
|
|
|
|
package api
|
|
|
|
import (
|
|
context "context"
|
|
http "github.com/go-kratos/kratos/v2/transport/http"
|
|
binding "github.com/go-kratos/kratos/v2/transport/http/binding"
|
|
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
|
)
|
|
|
|
// 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 OperationGreeterPing = "/api.Greeter/Ping"
|
|
const OperationGreeterPing2 = "/api.Greeter/Ping2"
|
|
|
|
type GreeterHTTPServer interface {
|
|
// Ping Sends a greeting
|
|
Ping(context.Context, *emptypb.Empty) (*PingReply, error)
|
|
Ping2(context.Context, *emptypb.Empty) (*PingReply, error)
|
|
}
|
|
|
|
func RegisterGreeterHTTPServer(s *http.Server, srv GreeterHTTPServer) {
|
|
r := s.Route("/")
|
|
r.GET("/ping", _Greeter_Ping0_HTTP_Handler(srv))
|
|
r.GET("/ping2", _Greeter_Ping20_HTTP_Handler(srv))
|
|
}
|
|
|
|
func _Greeter_Ping0_HTTP_Handler(srv GreeterHTTPServer) func(ctx http.Context) error {
|
|
return func(ctx http.Context) error {
|
|
var in emptypb.Empty
|
|
if err := ctx.BindQuery(&in); err != nil {
|
|
return err
|
|
}
|
|
http.SetOperation(ctx, OperationGreeterPing)
|
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.Ping(ctx, req.(*emptypb.Empty))
|
|
})
|
|
out, err := h(ctx, &in)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
reply := out.(*PingReply)
|
|
return ctx.Result(200, reply)
|
|
}
|
|
}
|
|
|
|
func _Greeter_Ping20_HTTP_Handler(srv GreeterHTTPServer) func(ctx http.Context) error {
|
|
return func(ctx http.Context) error {
|
|
var in emptypb.Empty
|
|
if err := ctx.BindQuery(&in); err != nil {
|
|
return err
|
|
}
|
|
http.SetOperation(ctx, OperationGreeterPing2)
|
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.Ping2(ctx, req.(*emptypb.Empty))
|
|
})
|
|
out, err := h(ctx, &in)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
reply := out.(*PingReply)
|
|
return ctx.Result(200, reply)
|
|
}
|
|
}
|
|
|
|
type GreeterHTTPClient interface {
|
|
Ping(ctx context.Context, req *emptypb.Empty, opts ...http.CallOption) (rsp *PingReply, err error)
|
|
Ping2(ctx context.Context, req *emptypb.Empty, opts ...http.CallOption) (rsp *PingReply, err error)
|
|
}
|
|
|
|
type GreeterHTTPClientImpl struct {
|
|
cc *http.Client
|
|
}
|
|
|
|
func NewGreeterHTTPClient(client *http.Client) GreeterHTTPClient {
|
|
return &GreeterHTTPClientImpl{client}
|
|
}
|
|
|
|
func (c *GreeterHTTPClientImpl) Ping(ctx context.Context, in *emptypb.Empty, opts ...http.CallOption) (*PingReply, error) {
|
|
var out PingReply
|
|
pattern := "/ping"
|
|
path := binding.EncodeURL(pattern, in, true)
|
|
opts = append(opts, http.Operation(OperationGreeterPing))
|
|
opts = append(opts, http.PathTemplate(pattern))
|
|
err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &out, err
|
|
}
|
|
|
|
func (c *GreeterHTTPClientImpl) Ping2(ctx context.Context, in *emptypb.Empty, opts ...http.CallOption) (*PingReply, error) {
|
|
var out PingReply
|
|
pattern := "/ping2"
|
|
path := binding.EncodeURL(pattern, in, true)
|
|
opts = append(opts, http.Operation(OperationGreeterPing2))
|
|
opts = append(opts, http.PathTemplate(pattern))
|
|
err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &out, err
|
|
}
|
|
|