// 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/b_api/helloworld.proto

package b_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 OperationBGreeterBSayHello = "/helloworld.BGreeter/BSayHello"

type BGreeterHTTPServer interface {
	// BSayHello Sends a greeting
	BSayHello(context.Context, *BHelloRequest) (*BHelloReply, error)
}

func RegisterBGreeterHTTPServer(s *http.Server, srv BGreeterHTTPServer) {
	r := s.Route("/")
	r.POST("/greet2b", _BGreeter_BSayHello0_HTTP_Handler(srv))
	r.GET("/greet1b", _BGreeter_BSayHello1_HTTP_Handler(srv))
}

func _BGreeter_BSayHello0_HTTP_Handler(srv BGreeterHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in BHelloRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationBGreeterBSayHello)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.BSayHello(ctx, req.(*BHelloRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		reply := out.(*BHelloReply)
		return ctx.Result(200, reply)
	}
}

func _BGreeter_BSayHello1_HTTP_Handler(srv BGreeterHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in BHelloRequest
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationBGreeterBSayHello)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.BSayHello(ctx, req.(*BHelloRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		reply := out.(*BHelloReply)
		return ctx.Result(200, reply)
	}
}

type BGreeterHTTPClient interface {
	BSayHello(ctx context.Context, req *BHelloRequest, opts ...http.CallOption) (rsp *BHelloReply, err error)
}

type BGreeterHTTPClientImpl struct {
	cc *http.Client
}

func NewBGreeterHTTPClient(client *http.Client) BGreeterHTTPClient {
	return &BGreeterHTTPClientImpl{client}
}

func (c *BGreeterHTTPClientImpl) BSayHello(ctx context.Context, in *BHelloRequest, opts ...http.CallOption) (*BHelloReply, error) {
	var out BHelloReply
	pattern := "/greet1b"
	path := binding.EncodeURL(pattern, in, true)
	opts = append(opts, http.Operation(OperationBGreeterBSayHello))
	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
}
