Documentation ¶
Index ¶
- Constants
- func NewRequestSignString(path, policy, body string) string
- type AppError
- type DownloadListResponse
- type FinishedListResponse
- type GeneralUploadCallbackFailed
- type ListRequest
- type RemoteDeleteRequest
- type RequestRawSign
- type Response
- func BuildDownloadingResponse(tasks []model.Download) Response
- func BuildFinishedListResponse(tasks []model.Download) Response
- func BuildShareList(shares []model.Share, total int) Response
- func BuildSiteConfig(settings map[string]string, user *model.User) Response
- func BuildTaskList(tasks []model.Task, total int) Response
- func BuildUserResponse(user model.User) Response
- func BuildUserStorageResponse(user model.User) Response
- func CheckLogin() Response
- func DBErr(msg string, err error) Response
- func Err(errCode int, msg string, err error) Response
- func ParamErr(msg string, err error) Response
- type Share
- type SiteConfig
- type UploadCallback
- type UploadCredential
- type UploadPolicy
- type UploadSession
- type User
- type WebAuthnCredentials
Constants ¶
const ( // CodeNotFullySuccess 未完全成功 CodeNotFullySuccess = 203 // CodeCheckLogin 未登录 CodeCheckLogin = 401 // CodeNoPermissionErr 未授权访问 CodeNoPermissionErr = 403 // CodeNotFound 资源未找到 CodeNotFound = 404 // CodeUploadFailed 上传出错 CodeUploadFailed = 40002 // CodeCreateFolderFailed 目录创建失败 CodeCreateFolderFailed = 40003 // CodeObjectExist 对象已存在 CodeObjectExist = 40004 // CodeSignExpired 签名过期 CodeSignExpired = 40005 // CodePolicyNotAllowed 当前存储策略不允许 CodePolicyNotAllowed = 40006 // CodeGroupNotAllowed 用户组无法进行此操作 CodeGroupNotAllowed = 40007 // CodeAdminRequired 非管理用户组 CodeAdminRequired = 40008 // CodeDBError 数据库操作失败 CodeDBError = 50001 // CodeEncryptError 加密失败 CodeEncryptError = 50002 // CodeIOFailed IO操作失败 CodeIOFailed = 50004 // CodeInternalSetting 内部设置参数错误 CodeInternalSetting = 50005 // CodeCacheOperation 缓存操作失败 CodeCacheOperation = 50006 // CodeCallbackError 回调失败 CodeCallbackError = 50007 //CodeParamErr 各种奇奇怪怪的参数错误 CodeParamErr = 40001 // CodeNotSet 未定错误,后续尝试从error中获取 CodeNotSet = -1 )
三位数错误编码为复用http原本含义 五位数错误编码为应用自定义错误 五开头的五位数错误编码为服务器端错误,比如数据库操作失败 四开头的五位数错误编码为客户端错误,有时候是客户端代码写错了,有时候是用户操作错误
Variables ¶
This section is empty.
Functions ¶
func NewRequestSignString ¶
NewRequestSignString 返回JSON格式的待签名字符串 TODO 测试
Types ¶
type DownloadListResponse ¶
type DownloadListResponse struct { UpdateTime int64 `json:"update"` UpdateInterval int `json:"interval"` Name string `json:"name"` Status int `json:"status"` Dst string `json:"dst"` Total uint64 `json:"total"` Downloaded uint64 `json:"downloaded"` Speed int `json:"speed"` Info rpc.StatusInfo `json:"info"` }
DownloadListResponse 下载列表响应条目
type FinishedListResponse ¶
type FinishedListResponse struct { Name string `json:"name"` Status int `json:"status"` Dst string `json:"dst"` Error string `json:"error"` Total uint64 `json:"total"` Files []rpc.FileInfo `json:"files"` TaskStatus int `json:"task_status"` TaskError string `json:"task_error"` CreateTime string `json:"create"` UpdateTime string `json:"update"` }
FinishedListResponse 已完成任务条目
type GeneralUploadCallbackFailed ¶
type GeneralUploadCallbackFailed struct {
Error string `json:"error"`
}
GeneralUploadCallbackFailed 存储策略上传回调失败响应
type ListRequest ¶
ListRequest 远程策略列文件请求正文
type RemoteDeleteRequest ¶
type RemoteDeleteRequest struct {
Files []string `json:"files"`
}
RemoteDeleteRequest 远程策略删除接口请求正文
type RequestRawSign ¶
RequestRawSign 待签名的HTTP请求
type Response ¶
type Response struct { Code int `json:"code"` Data interface{} `json:"data,omitempty"` Msg string `json:"msg"` Error string `json:"error,omitempty"` }
Response 基础序列化器
func BuildDownloadingResponse ¶
BuildDownloadingResponse 构建正在下载的列表响应
func BuildFinishedListResponse ¶
BuildFinishedListResponse 构建已完成任务条目
func BuildShareList ¶
BuildShareList 构建我的分享列表响应
func BuildSiteConfig ¶
BuildSiteConfig 站点全局设置
func BuildTaskList ¶
BuildTaskList 构建任务列表响应
func BuildUserStorageResponse ¶
func BuildUserStorageResponse(user model.User) Response
BuildUserStorageResponse 序列化用户存储概况响应
type SiteConfig ¶
type SiteConfig struct { SiteName string `json:"title"` SiteICPId string `json:"siteICPId"` LoginCaptcha bool `json:"loginCaptcha"` RegCaptcha bool `json:"regCaptcha"` ForgetCaptcha bool `json:"forgetCaptcha"` EmailActive bool `json:"emailActive"` Themes string `json:"themes"` DefaultTheme string `json:"defaultTheme"` HomepageViewMethod string `json:"home_view_method"` Authn bool `json:"authn"` User User `json:"user"` UseReCaptcha bool `json:"captcha_IsUseReCaptcha"` ReCaptchaKey string `json:"captcha_ReCaptchaKey"` }
SiteConfig 站点全局设置序列
type UploadCallback ¶
type UploadCallback struct { Name string `json:"name"` SourceName string `json:"source_name"` PicInfo string `json:"pic_info"` Size uint64 `json:"size"` }
UploadCallback 上传回调正文
type UploadCredential ¶
type UploadCredential struct { Token string `json:"token"` Policy string `json:"policy"` Path string `json:"path"` // 存储路径 AccessKey string `json:"ak"` KeyTime string `json:"key_time,omitempty"` // COS用有效期 Callback string `json:"callback,omitempty"` // 回调地址 Key string `json:"key,omitempty"` // 文件标识符,通常为回调key }
UploadCredential 返回给客户端的上传凭证
type UploadPolicy ¶
type UploadPolicy struct { SavePath string `json:"save_path"` FileName string `json:"file_name"` AutoRename bool `json:"auto_rename"` MaxSize uint64 `json:"max_size"` AllowedExtension []string `json:"allowed_extension"` CallbackURL string `json:"callback_url"` }
UploadPolicy slave模式下传递的上传策略
func DecodeUploadPolicy ¶
func DecodeUploadPolicy(raw string) (*UploadPolicy, error)
DecodeUploadPolicy 反序列化Header中携带的上传策略
func (*UploadPolicy) EncodeUploadPolicy ¶
func (policy *UploadPolicy) EncodeUploadPolicy() (string, error)
EncodeUploadPolicy 序列化Header中携带的上传策略
type UploadSession ¶
type UploadSession struct { Key string UID uint PolicyID uint VirtualPath string Name string Size uint64 SavePath string }
UploadSession 上传会话
type User ¶
type User struct { ID string `json:"id"` Email string `json:"user_name"` Nickname string `json:"nickname"` Status int `json:"status"` Avatar string `json:"avatar"` CreatedAt int64 `json:"created_at"` PreferredTheme string `json:"preferred_theme"` Anonymous bool `json:"anonymous"` Policy policy `json:"policy"` Group group `json:"group"` Tags []tag `json:"tags"` }
User 用户序列化器
type WebAuthnCredentials ¶
WebAuthnCredentials 外部验证器凭证
func BuildWebAuthnList ¶
func BuildWebAuthnList(credentials []webauthn.Credential) []WebAuthnCredentials
BuildWebAuthnList 构建设置页面凭证列表