You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

http.go 703 B

11 months ago
11 months ago
11 months ago
12345678910111213141516171819202122232425262728293031323334353637
  1. package http
  2. import (
  3. "fmt"
  4. "gitlink.org.cn/cloudream/common/consts/errorcode"
  5. "gitlink.org.cn/cloudream/common/pkgs/mq"
  6. )
  7. type Response struct {
  8. Code string `json:"code"`
  9. Message string `json:"message"`
  10. Data any `json:"data"`
  11. }
  12. func OK(data any) Response {
  13. return Response{
  14. Code: errorcode.OK,
  15. Message: "",
  16. Data: data,
  17. }
  18. }
  19. func Failed(code string, format string, args ...any) Response {
  20. return Response{
  21. Code: code,
  22. Message: fmt.Sprintf(format, args...),
  23. }
  24. }
  25. func FailedError(err error) Response {
  26. if codeErr, ok := err.(*mq.CodeMessageError); ok {
  27. return Failed(codeErr.Code, codeErr.Message)
  28. }
  29. return Failed(errorcode.OperationFailed, err.Error())
  30. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。