mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-14 12:23:43 +00:00
feat: support RESTful api (#33)
This commit is contained in:
1 parent
e292926697
commit
c6aa83194f
22 files changed
+603
-125
No files matched your search
+6
-13
@@ -1,16 +1,13 @@
|
||||
package base
|
||||
|
||||
import "errors"
|
||||
|
||||
type Status int
|
||||
type Status string
|
||||
|
||||
const (
|
||||
DownloadStatusPrepare Status = iota
|
||||
DownloadStatusReady
|
||||
DownloadStatusStart
|
||||
DownloadStatusPause
|
||||
DownloadStatusError
|
||||
DownloadStatusDone
|
||||
DownloadStatusReady Status = "ready"
|
||||
DownloadStatusRunning Status = "running"
|
||||
DownloadStatusPause Status = "pause"
|
||||
DownloadStatusError Status = "error"
|
||||
DownloadStatusDone Status = "done"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -24,7 +21,3 @@ const (
|
||||
|
||||
HttpHeaderRangeFormat = "bytes=%d-%d"
|
||||
)
|
||||
|
||||
var (
|
||||
DeleteErr = errors.New("delete")
|
||||
)
|
||||
+14
-16
@@ -3,38 +3,36 @@ package base
|
||||
// 下载请求
|
||||
type Request struct {
|
||||
// 下载链接
|
||||
Schema string
|
||||
// 下载链接
|
||||
URL string
|
||||
URL string `json:"url"`
|
||||
// 附加信息
|
||||
Extra interface{}
|
||||
Extra interface{} `json:"extra"`
|
||||
}
|
||||
|
||||
// 资源信息
|
||||
type Resource struct {
|
||||
Req *Request
|
||||
Req *Request `json:"req"`
|
||||
// 资源总大小
|
||||
Length int64
|
||||
Size int64 `json:"size"`
|
||||
// 是否支持断点下载
|
||||
Range bool
|
||||
Range bool `json:"range"`
|
||||
// 资源所包含的文件列表
|
||||
Files []*FileInfo
|
||||
Files []*FileInfo `json:"files"`
|
||||
}
|
||||
|
||||
type FileInfo struct {
|
||||
Name string
|
||||
Path string
|
||||
Size int64
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
// 下载选项
|
||||
type Options struct {
|
||||
// 保存文件名
|
||||
Name string
|
||||
Name string `json:"name"`
|
||||
// 保存目录
|
||||
Path string
|
||||
Path string `json:"path"`
|
||||
// 并发连接数
|
||||
Connections int
|
||||
// 下载的文件下标列表
|
||||
SelectFiles []int
|
||||
Connections int `json:"connections"`
|
||||
// 选择下载的文件下标列表
|
||||
SelectFiles []int `json:"select_files"`
|
||||
}
|
||||
Reference in new issue
Block a user