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.
151 lines
4.8 KiB
151 lines
4.8 KiB
// Code generated by protoc-gen-go-http. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-http v2.5.0
|
|
// - protoc v3.21.6
|
|
// source: api/customer/customer.proto
|
|
|
|
package customer
|
|
|
|
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 OperationCustomerGetVerifyCode = "/api.customer.Customer/GetVerifyCode"
|
|
const OperationCustomerLogin = "/api.customer.Customer/Login"
|
|
const OperationCustomerLogout = "/api.customer.Customer/Logout"
|
|
|
|
type CustomerHTTPServer interface {
|
|
GetVerifyCode(context.Context, *GetVerifyCodeReq) (*GetVerifyCodeReply, error)
|
|
Login(context.Context, *LoginReq) (*LoginReply, error)
|
|
Logout(context.Context, *LogoutReq) (*LogoutReply, error)
|
|
}
|
|
|
|
func RegisterCustomerHTTPServer(s *http.Server, srv CustomerHTTPServer) {
|
|
r := s.Route("/")
|
|
r.GET("/customer/get-verify-code/{phoneNumber}", _Customer_GetVerifyCode0_HTTP_Handler(srv))
|
|
r.POST("/customer/login", _Customer_Login0_HTTP_Handler(srv))
|
|
r.DELETE("/customer/logout", _Customer_Logout0_HTTP_Handler(srv))
|
|
}
|
|
|
|
func _Customer_GetVerifyCode0_HTTP_Handler(srv CustomerHTTPServer) func(ctx http.Context) error {
|
|
return func(ctx http.Context) error {
|
|
var in GetVerifyCodeReq
|
|
if err := ctx.BindQuery(&in); err != nil {
|
|
return err
|
|
}
|
|
if err := ctx.BindVars(&in); err != nil {
|
|
return err
|
|
}
|
|
http.SetOperation(ctx, OperationCustomerGetVerifyCode)
|
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.GetVerifyCode(ctx, req.(*GetVerifyCodeReq))
|
|
})
|
|
out, err := h(ctx, &in)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
reply := out.(*GetVerifyCodeReply)
|
|
return ctx.Result(200, reply)
|
|
}
|
|
}
|
|
|
|
func _Customer_Login0_HTTP_Handler(srv CustomerHTTPServer) func(ctx http.Context) error {
|
|
return func(ctx http.Context) error {
|
|
var in LoginReq
|
|
if err := ctx.Bind(&in); err != nil {
|
|
return err
|
|
}
|
|
http.SetOperation(ctx, OperationCustomerLogin)
|
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.Login(ctx, req.(*LoginReq))
|
|
})
|
|
out, err := h(ctx, &in)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
reply := out.(*LoginReply)
|
|
return ctx.Result(200, reply)
|
|
}
|
|
}
|
|
|
|
func _Customer_Logout0_HTTP_Handler(srv CustomerHTTPServer) func(ctx http.Context) error {
|
|
return func(ctx http.Context) error {
|
|
var in LogoutReq
|
|
if err := ctx.BindQuery(&in); err != nil {
|
|
return err
|
|
}
|
|
http.SetOperation(ctx, OperationCustomerLogout)
|
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.Logout(ctx, req.(*LogoutReq))
|
|
})
|
|
out, err := h(ctx, &in)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
reply := out.(*LogoutReply)
|
|
return ctx.Result(200, reply)
|
|
}
|
|
}
|
|
|
|
type CustomerHTTPClient interface {
|
|
GetVerifyCode(ctx context.Context, req *GetVerifyCodeReq, opts ...http.CallOption) (rsp *GetVerifyCodeReply, err error)
|
|
Login(ctx context.Context, req *LoginReq, opts ...http.CallOption) (rsp *LoginReply, err error)
|
|
Logout(ctx context.Context, req *LogoutReq, opts ...http.CallOption) (rsp *LogoutReply, err error)
|
|
}
|
|
|
|
type CustomerHTTPClientImpl struct {
|
|
cc *http.Client
|
|
}
|
|
|
|
func NewCustomerHTTPClient(client *http.Client) CustomerHTTPClient {
|
|
return &CustomerHTTPClientImpl{client}
|
|
}
|
|
|
|
func (c *CustomerHTTPClientImpl) GetVerifyCode(ctx context.Context, in *GetVerifyCodeReq, opts ...http.CallOption) (*GetVerifyCodeReply, error) {
|
|
var out GetVerifyCodeReply
|
|
pattern := "/customer/get-verify-code/{phoneNumber}"
|
|
path := binding.EncodeURL(pattern, in, true)
|
|
opts = append(opts, http.Operation(OperationCustomerGetVerifyCode))
|
|
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 *CustomerHTTPClientImpl) Login(ctx context.Context, in *LoginReq, opts ...http.CallOption) (*LoginReply, error) {
|
|
var out LoginReply
|
|
pattern := "/customer/login"
|
|
path := binding.EncodeURL(pattern, in, false)
|
|
opts = append(opts, http.Operation(OperationCustomerLogin))
|
|
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
|
|
}
|
|
|
|
func (c *CustomerHTTPClientImpl) Logout(ctx context.Context, in *LogoutReq, opts ...http.CallOption) (*LogoutReply, error) {
|
|
var out LogoutReply
|
|
pattern := "/customer/logout"
|
|
path := binding.EncodeURL(pattern, in, true)
|
|
opts = append(opts, http.Operation(OperationCustomerLogout))
|
|
opts = append(opts, http.PathTemplate(pattern))
|
|
err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &out, err
|
|
}
|