diff --git a/app/http/controllers/plugins/pureftpd_controller.go b/app/http/controllers/plugins/pureftpd_controller.go index 40a11de5..fa87fec2 100644 --- a/app/http/controllers/plugins/pureftpd_controller.go +++ b/app/http/controllers/plugins/pureftpd_controller.go @@ -9,16 +9,12 @@ import ( "github.com/TheTNB/panel/app/http/controllers" "github.com/TheTNB/panel/pkg/tools" + "github.com/TheTNB/panel/types" ) type PureFtpdController struct { } -type User struct { - Username string `json:"username"` - Path string `json:"path"` -} - func NewPureFtpdController() *PureFtpdController { return &PureFtpdController{} } @@ -29,19 +25,19 @@ func (r *PureFtpdController) List(ctx http.Context) http.Response { if err != nil { return controllers.Success(ctx, http.Json{ "total": 0, - "items": []User{}, + "items": []types.PureFtpdUser{}, }) } listArr := strings.Split(listRaw, "\n") - var users []User + var users []types.PureFtpdUser for _, v := range listArr { if len(v) == 0 { continue } match := regexp.MustCompile(`(\S+)\s+(\S+)`).FindStringSubmatch(v) - users = append(users, User{ + users = append(users, types.PureFtpdUser{ Username: match[1], Path: strings.Replace(match[2], "/./", "/", 1), }) @@ -54,7 +50,7 @@ func (r *PureFtpdController) List(ctx http.Context) http.Response { if startIndex > len(users) { return controllers.Success(ctx, http.Json{ "total": 0, - "items": []User{}, + "items": []types.PureFtpdUser{}, }) } if endIndex > len(users) { diff --git a/types/pureftpd.go b/types/pureftpd.go new file mode 100644 index 00000000..d1208bff --- /dev/null +++ b/types/pureftpd.go @@ -0,0 +1,6 @@ +package types + +type PureFtpdUser struct { + Username string `json:"username"` + Path string `json:"path"` +}