// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.8.0
// - protoc             v3.12.4
// source: svapi/favorite.proto

package svapi

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 OperationFavoriteServiceAddFavorite = "/svapi.FavoriteService/AddFavorite"
const OperationFavoriteServiceListFavoriteVideo = "/svapi.FavoriteService/ListFavoriteVideo"
const OperationFavoriteServiceRemoveFavorite = "/svapi.FavoriteService/RemoveFavorite"

type FavoriteServiceHTTPServer interface {
	AddFavorite(context.Context, *AddFavoriteRequest) (*AddFavoriteResponse, error)
	ListFavoriteVideo(context.Context, *ListFavoriteVideoRequest) (*ListFavoriteVideoResponse, error)
	RemoveFavorite(context.Context, *RemoveFavoriteRequest) (*RemoveFavoriteResponse, error)
}

func RegisterFavoriteServiceHTTPServer(s *http.Server, srv FavoriteServiceHTTPServer) {
	r := s.Route("/")
	r.POST("/favorite", _FavoriteService_AddFavorite0_HTTP_Handler(srv))
	r.DELETE("/favorite", _FavoriteService_RemoveFavorite0_HTTP_Handler(srv))
	r.POST("/favorite/video/list", _FavoriteService_ListFavoriteVideo0_HTTP_Handler(srv))
}

func _FavoriteService_AddFavorite0_HTTP_Handler(srv FavoriteServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in AddFavoriteRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationFavoriteServiceAddFavorite)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.AddFavorite(ctx, req.(*AddFavoriteRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

func _FavoriteService_RemoveFavorite0_HTTP_Handler(srv FavoriteServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in RemoveFavoriteRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationFavoriteServiceRemoveFavorite)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.RemoveFavorite(ctx, req.(*RemoveFavoriteRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

func _FavoriteService_ListFavoriteVideo0_HTTP_Handler(srv FavoriteServiceHTTPServer) func(ctx http.Context) error {
	return func(ctx http.Context) error {
		var in ListFavoriteVideoRequest
		if err := ctx.Bind(&in); err != nil {
			return err
		}
		if err := ctx.BindQuery(&in); err != nil {
			return err
		}
		http.SetOperation(ctx, OperationFavoriteServiceListFavoriteVideo)
		h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
			return srv.ListFavoriteVideo(ctx, req.(*ListFavoriteVideoRequest))
		})
		out, err := h(ctx, &in)
		if err != nil {
			return err
		}
		return ctx.Result(200, out)
	}
}

type FavoriteServiceHTTPClient interface {
	AddFavorite(ctx context.Context, req *AddFavoriteRequest, opts ...http.CallOption) (rsp *AddFavoriteResponse, err error)
	ListFavoriteVideo(ctx context.Context, req *ListFavoriteVideoRequest, opts ...http.CallOption) (rsp *ListFavoriteVideoResponse, err error)
	RemoveFavorite(ctx context.Context, req *RemoveFavoriteRequest, opts ...http.CallOption) (rsp *RemoveFavoriteResponse, err error)
}

type FavoriteServiceHTTPClientImpl struct {
	cc *http.Client
}

func NewFavoriteServiceHTTPClient(client *http.Client) FavoriteServiceHTTPClient {
	return &FavoriteServiceHTTPClientImpl{client}
}

func (c *FavoriteServiceHTTPClientImpl) AddFavorite(ctx context.Context, in *AddFavoriteRequest, opts ...http.CallOption) (*AddFavoriteResponse, error) {
	var out AddFavoriteResponse
	pattern := "/favorite"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationFavoriteServiceAddFavorite))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, nil
}

func (c *FavoriteServiceHTTPClientImpl) ListFavoriteVideo(ctx context.Context, in *ListFavoriteVideoRequest, opts ...http.CallOption) (*ListFavoriteVideoResponse, error) {
	var out ListFavoriteVideoResponse
	pattern := "/favorite/video/list"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationFavoriteServiceListFavoriteVideo))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, nil
}

func (c *FavoriteServiceHTTPClientImpl) RemoveFavorite(ctx context.Context, in *RemoveFavoriteRequest, opts ...http.CallOption) (*RemoveFavoriteResponse, error) {
	var out RemoveFavoriteResponse
	pattern := "/favorite"
	path := binding.EncodeURL(pattern, in, false)
	opts = append(opts, http.Operation(OperationFavoriteServiceRemoveFavorite))
	opts = append(opts, http.PathTemplate(pattern))
	err := c.cc.Invoke(ctx, "DELETE", path, in, &out, opts...)
	if err != nil {
		return nil, err
	}
	return &out, nil
}
