feat: add alist v3 driver (close #1833 pr #2129)

* feat: add alist v3 driver (close #1833)

* chore: use generics

Co-authored-by: Noah Hsu <i@nn.ci>
This commit is contained in:
BoYanZh
2022-10-27 10:54:49 +08:00
committed by GitHub
parent f0cc0a76a9
commit 5f79d665d9
7 changed files with 165 additions and 8 deletions

View File

@ -28,7 +28,7 @@ func ErrorResp(c *gin.Context, err error, code int, l ...bool) {
log.Errorf("%v", err)
}
}
c.JSON(200, Resp{
c.JSON(200, Resp[interface{}]{
Code: code,
Message: hidePrivacy(err.Error()),
Data: nil,
@ -40,7 +40,7 @@ func ErrorStrResp(c *gin.Context, str string, code int, l ...bool) {
if len(l) != 0 && l[0] {
log.Error(str)
}
c.JSON(200, Resp{
c.JSON(200, Resp[interface{}]{
Code: code,
Message: hidePrivacy(str),
Data: nil,
@ -50,14 +50,14 @@ func ErrorStrResp(c *gin.Context, str string, code int, l ...bool) {
func SuccessResp(c *gin.Context, data ...interface{}) {
if len(data) == 0 {
c.JSON(200, Resp{
c.JSON(200, Resp[interface{}]{
Code: 200,
Message: "success",
Data: nil,
})
return
}
c.JSON(200, Resp{
c.JSON(200, Resp[interface{}]{
Code: 200,
Message: "success",
Data: data[0],