alist/server/handles/driver.go

29 lines
640 B
Go
Raw Normal View History

2022-07-11 17:12:50 +08:00
package handles
2022-06-26 20:25:02 +08:00
import (
2022-06-26 20:31:04 +08:00
"fmt"
2022-08-03 14:26:59 +08:00
2022-06-26 20:25:02 +08:00
"github.com/alist-org/alist/v3/internal/operations"
"github.com/alist-org/alist/v3/server/common"
"github.com/gin-gonic/gin"
)
func ListDriverItems(c *gin.Context) {
common.SuccessResp(c, operations.GetDriverItemsMap())
}
func ListDriverNames(c *gin.Context) {
common.SuccessResp(c, operations.GetDriverNames())
}
func GetDriverItems(c *gin.Context) {
driverName := c.Query("driver")
itemsMap := operations.GetDriverItemsMap()
items, ok := itemsMap[driverName]
if !ok {
2022-06-26 20:31:04 +08:00
common.ErrorStrResp(c, fmt.Sprintf("driver [%s] not found", driverName), 404)
2022-06-26 20:25:02 +08:00
return
}
2022-06-26 20:31:04 +08:00
common.SuccessResp(c, items)
2022-06-26 20:25:02 +08:00
}