// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.6.3
// - protoc             v4.23.4
// source: interface/web3/defi.proto

package web3

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 OperationDefiGetTokenPrice = "/api.interface.web3.Defi/GetTokenPrice"

type DefiHTTPServer interface {
	GetTokenPrice(context.Context, *GetTokenPriceRequest) (*GetTokenPriceReply, error)
}

func RegisterDefiHTTPServer(s *http.Server, srv DefiHTTPServer) {
	r := s.Route("/")
	r.GET("/api/gateway/interface/web3/defi/price", _Defi_GetTokenPrice0_HTTP_Handler(srv))
}

func _Defi_GetTokenPrice0_HTTP_Handler(srv DefiHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in GetTokenPriceRequest
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationDefiGetTokenPrice)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.GetTokenPrice(ctx, req.(*GetTokenPriceRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		reply := out.(*GetTokenPriceReply)
		return ctx.Result(200, reply)
	}
}

type DefiHTTPClient interface {
	GetTokenPrice(ctx context.Context, req *GetTokenPriceRequest, opts ...http.CallOption) (rsp *GetTokenPriceReply, err error)
}

type DefiHTTPClientImpl struct {
	cc *http.Client
}

func NewDefiHTTPClient(client *http.Client) DefiHTTPClient {
	return &DefiHTTPClientImpl{client}
}

func (c *DefiHTTPClientImpl) GetTokenPrice(ctx context.Context, in *GetTokenPriceRequest, opts ...http.CallOption) (*GetTokenPriceReply, error) {
	var out GetTokenPriceReply
	pattern := "/api/gateway/interface/web3/defi/price"
	path := binding.EncodeURL(pattern, in, true)
	opts = append(opts, http.Operation(OperationDefiGetTokenPrice))
	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
}
