webapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientAPI

type ClientAPI interface {
	Status() ed2k.ClientStatus
	TransferSnapshots() []ed2k.TransferSnapshot
	AddLink(linkValue, outputDir string) (ed2k.TransferHandle, string, error)
	PauseTransfer(hash protocol.Hash) error
	ResumeTransfer(hash protocol.Hash) error
	RemoveTransfer(hash protocol.Hash, deleteFile bool) error
}

ClientAPI 是 Web API 所需的客户端操作子集。

type Handler

type Handler struct {
	Client        ClientAPI
	DefaultOutDir string
	User          string
	Pass          string
}

Handler 提供基于 net/http 的 REST API。

func NewHandler

func NewHandler(client ClientAPI, defaultOutDir, user, pass string) *Handler

NewHandler 创建 API 处理器。user/pass 均非空时启用 Basic Auth。

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP 分发 REST 路由。

Jump to

Keyboard shortcuts

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