client

package
v0.7.260410 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package client 提供 HTTP 客户端命令。

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:     "client",
	Usage:    "HTTP 客户端工具",
	Action:   action,
	Commands: []*cli.Command{version.Command, healthCommand, getCommand},
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "url",
			Aliases: []string{"s"},
			Value:   dc.Client.URL,
			Usage:   "服务器地址",
		},
		&cli.DurationFlag{
			Name:  "timeout",
			Value: dc.Client.Timeout,
			Usage: "请求超时时间",
		},
		&cli.IntFlag{
			Name:  "retries",
			Value: dc.Client.Retries,
			Usage: "重试次数",
		},
	},
}

Command 客户端命令

Functions

This section is empty.

Types

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

HTTPClient HTTP 客户端封装

func NewHTTPClient

func NewHTTPClient(cfg *config.ClientConfig) *HTTPClient

NewHTTPClient 创建新的 HTTP 客户端

func (*HTTPClient) Get

func (c *HTTPClient) Get(ctx context.Context, path string) (string, error)

Get 发送 GET 请求

func (*HTTPClient) Health

func (c *HTTPClient) Health(ctx context.Context) (*HealthResponse, error)

Health 执行健康检查

type HealthResponse

type HealthResponse struct {
	Status string `json:"status"`
}

HealthResponse 健康检查响应

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL