// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.8.0
// - protoc             v5.27.1
// source: test.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 OperationTestServiceTest = "/api.TestService/Test"

type TestServiceHTTPServer interface {
	Test(context.Context, *TestRequest) (*TestResponse, error)
}

func RegisterTestServiceHTTPServer(s *http.Server, srv TestServiceHTTPServer) {
	r := s.Route("/")
	r.GET("/test", _TestService_Test0_HTTP_Handler(srv))
}

func _TestService_Test0_HTTP_Handler(srv TestServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in TestRequest
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationTestServiceTest)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.Test(ctx, req.(*TestRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

type TestServiceHTTPClient interface {
	Test(ctx context.Context, req *TestRequest, opts ...http.CallOption) (rsp *TestResponse, err error)
}

type TestServiceHTTPClientImpl struct {
	cc *http.Client
}

func NewTestServiceHTTPClient(client *http.Client) TestServiceHTTPClient {
	return &TestServiceHTTPClientImpl{client}
}

func (c *TestServiceHTTPClientImpl) Test(ctx context.Context, in *TestRequest, opts ...http.CallOption) (*TestResponse, error) {
	var out TestResponse
	pattern := "/test"
	path := binding.EncodeURL(pattern, in, true)
	opts = append(opts, http.Operation(OperationTestServiceTest))
	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
}
