httper

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConfig

func CreateConfig(data map[string]string, name string, t string) error

CreateConfig 创建配置(占位符实现)

func DeleteConfigByName

func DeleteConfigByName(name string) error

DeleteConfigByName 删除配置(CasaOS 兼容)

func GetConfigByName

func GetConfigByName(name string) (map[string]string, error)

GetConfigByName 根据名称获取配置(CasaOS 兼容)

func GetJSON

func GetJSON(url string, v interface{}) error

GetJSON 获取并解析 JSON

func Mount

func Mount(mountPoint, fs string) error

Mount 挂载存储(占位符实现)

func OasisGet

func OasisGet(url string) string

OasisGet 获取远程数据(兼容函数)

func PostJSON

func PostJSON(url string, body interface{}, v interface{}) error

PostJSON 发送 JSON 并解析响应

func ReadZeroTierAuthToken

func ReadZeroTierAuthToken() (string, error)

ReadZeroTierAuthToken 从文件读取认证令牌

func Unmount

func Unmount(mountPoint string) error

Unmount 卸载存储(占位符实现)

Types

type Client

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

Client HTTP 客户端

func NewClient

func NewClient() *Client

NewClient 创建 HTTP 客户端

func (*Client) Delete

func (c *Client) Delete(path string) (*Response, error)

Delete 发送 DELETE 请求

func (*Client) DeleteContext

func (c *Client) DeleteContext(ctx context.Context, path string) (*Response, error)

DeleteContext 发送带上下文的 DELETE 请求

func (*Client) Download

func (c *Client) Download(url, savePath string, onProgress func(current, total int64)) error

Download 下载文件

func (*Client) DownloadContext

func (c *Client) DownloadContext(ctx context.Context, downloadURL, savePath string, onProgress func(current, total int64)) error

DownloadContext 带上下文下载文件

func (*Client) Get

func (c *Client) Get(path string) (*Response, error)

Get 发送 GET 请求

func (*Client) GetContext

func (c *Client) GetContext(ctx context.Context, path string) (*Response, error)

GetContext 发送带上下文的 GET 请求

func (*Client) Patch

func (c *Client) Patch(path string, body interface{}) (*Response, error)

Patch 发送 PATCH 请求

func (*Client) PatchContext

func (c *Client) PatchContext(ctx context.Context, path string, body interface{}) (*Response, error)

PatchContext 发送带上下文的 PATCH 请求

func (*Client) Post

func (c *Client) Post(path string, body interface{}) (*Response, error)

Post 发送 POST 请求

func (*Client) PostContext

func (c *Client) PostContext(ctx context.Context, path string, body interface{}) (*Response, error)

PostContext 发送带上下文的 POST 请求

func (*Client) PostForm

func (c *Client) PostForm(path string, data url.Values) (*Response, error)

PostForm 发送表单 POST 请求

func (*Client) PostFormContext

func (c *Client) PostFormContext(ctx context.Context, path string, data url.Values) (*Response, error)

PostFormContext 发送带上下文的表单 POST 请求

func (*Client) Put

func (c *Client) Put(path string, body interface{}) (*Response, error)

Put 发送 PUT 请求

func (*Client) PutContext

func (c *Client) PutContext(ctx context.Context, path string, body interface{}) (*Response, error)

PutContext 发送带上下文的 PUT 请求

func (*Client) WithBaseURL

func (c *Client) WithBaseURL(baseURL string) *Client

WithBaseURL 设置基础 URL

func (*Client) WithBearerToken

func (c *Client) WithBearerToken(token string) *Client

WithBearerToken 设置 Bearer Token

func (*Client) WithHeader

func (c *Client) WithHeader(key, value string) *Client

WithHeader 设置请求头

func (*Client) WithHeaders

func (c *Client) WithHeaders(headers map[string]string) *Client

WithHeaders 设置多个请求头

func (*Client) WithRetry

func (c *Client) WithRetry(count int, delay time.Duration) *Client

WithRetry 设置重试配置

func (*Client) WithTimeout

func (c *Client) WithTimeout(timeout time.Duration) *Client

WithTimeout 设置超时时间

type DriveClient

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

DriveClient 网盘/云存储客户端

func NewDriveClient

func NewDriveClient(baseURL, authToken string) *DriveClient

NewDriveClient 创建网盘客户端

func (*DriveClient) Copy

func (d *DriveClient) Copy(srcPath, dstPath string) error

Copy 复制文件/目录

func (*DriveClient) CreateDir

func (d *DriveClient) CreateDir(path string) error

CreateDir 创建目录

func (*DriveClient) Delete

func (d *DriveClient) Delete(path string) error

Delete 删除文件/目录

func (*DriveClient) Download

func (d *DriveClient) Download(remotePath, localPath string) error

Download 下载文件

func (*DriveClient) GetInfo

func (d *DriveClient) GetInfo(path string) (*DriveFile, error)

GetInfo 获取文件/目录信息

func (*DriveClient) GetQuota

func (d *DriveClient) GetQuota() (*DriveQuota, error)

GetQuota 获取存储配额

func (d *DriveClient) GetShareLink(path string, expiry time.Duration) (string, error)

GetShareLink 获取分享链接

func (*DriveClient) List

func (d *DriveClient) List(path string) ([]DriveFile, error)

List 列出目录内容

func (*DriveClient) Move

func (d *DriveClient) Move(srcPath, dstPath string) error

Move 移动文件/目录

func (*DriveClient) Rename

func (d *DriveClient) Rename(path, newName string) error

Rename 重命名文件/目录

func (*DriveClient) Search

func (d *DriveClient) Search(query string) ([]DriveFile, error)

Search 搜索文件

func (*DriveClient) SetAuthToken

func (d *DriveClient) SetAuthToken(token string) *DriveClient

SetAuthToken 设置认证令牌

func (*DriveClient) Upload

func (d *DriveClient) Upload(localPath, remotePath string) error

Upload 上传文件

type DriveFile

type DriveFile struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Path        string    `json:"path"`
	Size        int64     `json:"size"`
	IsDir       bool      `json:"is_dir"`
	MimeType    string    `json:"mime_type"`
	ModifiedAt  time.Time `json:"modified_at"`
	CreatedAt   time.Time `json:"created_at"`
	DownloadURL string    `json:"download_url,omitempty"`
	ParentID    string    `json:"parent_id,omitempty"`
}

DriveFile 文件信息

type DriveQuota

type DriveQuota struct {
	Total int64 `json:"total"`
	Used  int64 `json:"used"`
	Free  int64 `json:"free"`
}

DriveQuota 配额信息

type MountList

type MountList struct {
	MountPoints []MountPoint `json:"mountPoints"`
}

MountList 挂载列表

func GetMountList

func GetMountList() (MountList, error)

GetMountList 获取挂载列表(占位符实现)

type MountPoint

type MountPoint struct {
	MountPoint string `json:"MountPoint"`
	Fs         string `json:"Fs"`
}

MountPoint 挂载点信息

type RemotesResult

type RemotesResult struct {
	Remotes map[string]map[string]string `json:"remotes"`
}

RemotesResult 远程配置结果

func GetAllConfigName

func GetAllConfigName() (RemotesResult, error)

GetAllConfigName 获取所有配置名称(CasaOS 兼容)

func GetRemotes

func GetRemotes() (RemotesResult, error)

GetRemotes 获取远程配置(占位符实现)

type Response

type Response struct {
	StatusCode int
	Headers    http.Header
	Body       []byte
}

Response HTTP 响应

func Get

func Get(url string) (*Response, error)

Get 快捷 GET 请求

func Post

func Post(url string, body interface{}) (*Response, error)

Post 快捷 POST 请求

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

IsSuccess 检查是否成功响应

func (*Response) JSON

func (r *Response) JSON(v interface{}) error

JSON 将响应体解析为 JSON

func (*Response) String

func (r *Response) String() string

String 返回响应体字符串

type ZeroTierClient

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

ZeroTierClient ZeroTier API 客户端

func NewZeroTierClient

func NewZeroTierClient(authToken string) *ZeroTierClient

NewZeroTierClient 创建 ZeroTier 客户端

func NewZeroTierClientWithURL

func NewZeroTierClientWithURL(baseURL, authToken string) *ZeroTierClient

NewZeroTierClientWithURL 创建指定 URL 的 ZeroTier 客户端

func (*ZeroTierClient) GetAddress

func (z *ZeroTierClient) GetAddress() (string, error)

GetAddress 获取本机 ZeroTier 地址

func (*ZeroTierClient) GetNetwork

func (z *ZeroTierClient) GetNetwork(networkID string) (*ZeroTierNetwork, error)

GetNetwork 获取网络详情

func (*ZeroTierClient) GetNetworkIPs

func (z *ZeroTierClient) GetNetworkIPs(networkID string) ([]string, error)

GetNetworkIPs 获取网络分配的 IP 地址

func (*ZeroTierClient) GetPeer

func (z *ZeroTierClient) GetPeer(address string) (*ZeroTierPeer, error)

GetPeer 获取节点详情

func (*ZeroTierClient) GetStatus

func (z *ZeroTierClient) GetStatus() (*ZeroTierStatus, error)

GetStatus 获取服务状态

func (*ZeroTierClient) GetVersion

func (z *ZeroTierClient) GetVersion() (string, error)

GetVersion 获取版本号

func (*ZeroTierClient) IsOnline

func (z *ZeroTierClient) IsOnline() bool

IsOnline 检查是否在线

func (*ZeroTierClient) JoinNetwork

func (z *ZeroTierClient) JoinNetwork(networkID string) (*ZeroTierNetwork, error)

JoinNetwork 加入网络

func (*ZeroTierClient) LeaveNetwork

func (z *ZeroTierClient) LeaveNetwork(networkID string) error

LeaveNetwork 离开网络

func (*ZeroTierClient) ListNetworks

func (z *ZeroTierClient) ListNetworks() ([]ZeroTierNetwork, error)

ListNetworks 列出已加入的网络

func (*ZeroTierClient) ListPeers

func (z *ZeroTierClient) ListPeers() ([]ZeroTierPeer, error)

ListPeers 列出节点

func (*ZeroTierClient) WaitForNetwork

func (z *ZeroTierClient) WaitForNetwork(networkID string, timeout time.Duration) error

WaitForNetwork 等待网络就绪

type ZeroTierNetwork

type ZeroTierNetwork struct {
	ID                string   `json:"id"`
	Name              string   `json:"name"`
	Status            string   `json:"status"`
	MAC               string   `json:"mac"`
	AssignedAddresses []string `json:"assignedAddresses"`
	AllowManaged      bool     `json:"allowManaged"`
	AllowGlobal       bool     `json:"allowGlobal"`
	AllowDefault      bool     `json:"allowDefault"`
	AllowDNS          bool     `json:"allowDNS"`
	Bridge            bool     `json:"bridge"`
	BroadcastEnabled  bool     `json:"broadcastEnabled"`
	PortDeviceName    string   `json:"portDeviceName"`
	NetconfRevision   int      `json:"netconfRevision"`
}

ZeroTierNetwork 网络信息

type ZeroTierPath

type ZeroTierPath struct {
	Active        bool   `json:"active"`
	Address       string `json:"address"`
	LastReceive   int64  `json:"lastReceive"`
	LastSend      int64  `json:"lastSend"`
	Preferred     bool   `json:"preferred"`
	TrustedPathID int64  `json:"trustedPathId"`
}

ZeroTierPath 路径信息

type ZeroTierPeer

type ZeroTierPeer struct {
	Address string         `json:"address"`
	Latency int            `json:"latency"`
	Role    string         `json:"role"`
	Version string         `json:"version"`
	Paths   []ZeroTierPath `json:"paths"`
}

ZeroTierPeer 节点信息

type ZeroTierStatus

type ZeroTierStatus struct {
	Address           string `json:"address"`
	Clock             int64  `json:"clock"`
	ClusterNode       string `json:"clusterNode,omitempty"`
	Online            bool   `json:"online"`
	PublicIdentity    string `json:"publicIdentity"`
	TCPFallbackActive bool   `json:"tcpFallbackActive"`
	Version           string `json:"version"`
	VersionBuild      int    `json:"versionBuild"`
	VersionMajor      int    `json:"versionMajor"`
	VersionMinor      int    `json:"versionMinor"`
	VersionRev        int    `json:"versionRev"`
}

ZeroTierStatus 服务状态

Jump to

Keyboard shortcuts

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