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.

79 lines
2.2 KiB

// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.7.0
// - protoc v3.21.12
// source: email.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"
)
// 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 OperationEmailSendEmail = "/api.Email/SendEmail"
type EmailHTTPServer interface {
// SendEmail 发送一个邮件
SendEmail(context.Context, *SendRequest) (*SendEmailReply, error)
}
func RegisterEmailHTTPServer(s *http.Server, srv EmailHTTPServer) {
r := s.Route("/")
r.POST("email/send", _Email_SendEmail0_HTTP_Handler(srv))
}
func _Email_SendEmail0_HTTP_Handler(srv EmailHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in SendRequest
if err := ctx.Bind(&in); err != nil {
return err
}
if err := ctx.BindQuery(&in); err != nil {
return err
}
http.SetOperation(ctx, OperationEmailSendEmail)
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.SendEmail(ctx, req.(*SendRequest))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*SendEmailReply)
return ctx.Result(200, reply)
}
}
type EmailHTTPClient interface {
SendEmail(ctx context.Context, req *SendRequest, opts ...http.CallOption) (rsp *SendEmailReply, err error)
}
type EmailHTTPClientImpl struct {
cc *http.Client
}
func NewEmailHTTPClient(client *http.Client) EmailHTTPClient {
return &EmailHTTPClientImpl{client}
}
func (c *EmailHTTPClientImpl) SendEmail(ctx context.Context, in *SendRequest, opts ...http.CallOption) (*SendEmailReply, error) {
var out SendEmailReply
pattern := "email/send"
path := binding.EncodeURL(pattern, in, false)
opts = append(opts, http.Operation(OperationEmailSendEmail))
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
}