| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | package endpointimport (	"context"	"github.com/go-kit/kit/endpoint"	"github.com/longjoy/micro-go-course/section28/comment/service"	"log")type CommentsEndpoints struct {	CommentsListEndpoint endpoint.Endpoint	HealthCheckEndpoint  endpoint.Endpoint}// 服务发现请求结构体type CommentsListRequest struct {	Id string}// 服务发现响应结构体type CommentsListResponse struct {	Detail service.CommentListVO `json:"detail"`	Error  string                `json:"error"`}func MakeCommentsListEndpoint(svc service.Service) endpoint.Endpoint {	return func(ctx context.Context, request interface{}) (response interface{}, err error) {		req := request.(CommentsListRequest)		detail, err := svc.GetCommentsList(ctx, req.Id)		var errString = ""		if err != nil {			errString = err.Error()		}		return &CommentsListResponse{			Detail: detail,			Error:  errString,		}, nil	}}// HealthRequest 健康检查请求结构type HealthRequest struct{}// HealthResponse 健康检查响应结构type HealthResponse struct {	Status string `json:"status"`}// MakeHealthCheckEndpoint 创建健康检查Endpointfunc MakeHealthCheckEndpoint(svc service.Service) endpoint.Endpoint {	return func(ctx context.Context, request interface{}) (response interface{}, err error) {		log.Printf("helthcheck")		status := svc.HealthCheck()		return HealthResponse{			Status: status,		}, nil	}}
 |