@@ -2,7 +2,7 @@ package api
22
33import (
44 "github.com/0xJacky/Nginx-UI/server/model"
5- tool2 "github.com/0xJacky/Nginx-UI/server/tool"
5+ "github.com/0xJacky/Nginx-UI/server/tool"
66 "github.com/gin-gonic/gin"
77 "io/ioutil"
88 "net/http"
@@ -20,14 +20,14 @@ func GetDomains(c *gin.Context) {
2020 "modify" : "time" ,
2121 }
2222
23- configFiles , err := ioutil .ReadDir (tool2 .GetNginxConfPath ("sites-available" ))
23+ configFiles , err := ioutil .ReadDir (tool .GetNginxConfPath ("sites-available" ))
2424
2525 if err != nil {
2626 ErrHandler (c , err )
2727 return
2828 }
2929
30- enabledConfig , err := ioutil .ReadDir (filepath .Join (tool2 .GetNginxConfPath ("sites-enabled" )))
30+ enabledConfig , err := ioutil .ReadDir (filepath .Join (tool .GetNginxConfPath ("sites-enabled" )))
3131
3232 enabledConfigMap := make (map [string ]bool )
3333 for i := range enabledConfig {
@@ -53,7 +53,7 @@ func GetDomains(c *gin.Context) {
5353 }
5454 }
5555
56- configs = tool2 .Sort (orderBy , sort , mySort [orderBy ], configs )
56+ configs = tool .Sort (orderBy , sort , mySort [orderBy ], configs )
5757
5858 c .JSON (http .StatusOK , gin.H {
5959 "configs" : configs ,
@@ -62,10 +62,10 @@ func GetDomains(c *gin.Context) {
6262
6363func GetDomain (c * gin.Context ) {
6464 name := c .Param ("name" )
65- path := filepath .Join (tool2 .GetNginxConfPath ("sites-available" ), name )
65+ path := filepath .Join (tool .GetNginxConfPath ("sites-available" ), name )
6666
6767 enabled := true
68- if _ , err := os .Stat (filepath .Join (tool2 .GetNginxConfPath ("sites-enabled" ), name )); os .IsNotExist (err ) {
68+ if _ , err := os .Stat (filepath .Join (tool .GetNginxConfPath ("sites-enabled" ), name )); os .IsNotExist (err ) {
6969 enabled = false
7070 }
7171
@@ -98,26 +98,26 @@ func EditDomain(c *gin.Context) {
9898 name := c .Param ("name" )
9999 request := make (gin.H )
100100 err = c .BindJSON (& request )
101- path := filepath .Join (tool2 .GetNginxConfPath ("sites-available" ), name )
101+ path := filepath .Join (tool .GetNginxConfPath ("sites-available" ), name )
102102
103103 err = ioutil .WriteFile (path , []byte (request ["content" ].(string )), 0644 )
104104 if err != nil {
105105 ErrHandler (c , err )
106106 return
107107 }
108108
109- enabledConfigFilePath := filepath .Join (tool2 .GetNginxConfPath ("sites-enabled" ), name )
109+ enabledConfigFilePath := filepath .Join (tool .GetNginxConfPath ("sites-enabled" ), name )
110110 if _ , err = os .Stat (enabledConfigFilePath ); err == nil {
111111 // 测试配置文件
112- err = tool2 .TestNginxConf (enabledConfigFilePath )
112+ err = tool .TestNginxConf (enabledConfigFilePath )
113113 if err != nil {
114114 c .JSON (http .StatusInternalServerError , gin.H {
115115 "message" : err .Error (),
116116 })
117117 return
118118 }
119119
120- output := tool2 .ReloadNginx ()
120+ output := tool .ReloadNginx ()
121121
122122 if output != "" {
123123 c .JSON (http .StatusInternalServerError , gin.H {
@@ -131,8 +131,8 @@ func EditDomain(c *gin.Context) {
131131}
132132
133133func EnableDomain (c * gin.Context ) {
134- configFilePath := filepath .Join (tool2 .GetNginxConfPath ("sites-available" ), c .Param ("name" ))
135- enabledConfigFilePath := filepath .Join (tool2 .GetNginxConfPath ("sites-enabled" ), c .Param ("name" ))
134+ configFilePath := filepath .Join (tool .GetNginxConfPath ("sites-available" ), c .Param ("name" ))
135+ enabledConfigFilePath := filepath .Join (tool .GetNginxConfPath ("sites-enabled" ), c .Param ("name" ))
136136
137137 _ , err := os .Stat (configFilePath )
138138
@@ -149,7 +149,7 @@ func EnableDomain(c *gin.Context) {
149149 }
150150
151151 // 测试配置文件,不通过则撤回启用
152- err = tool2 .TestNginxConf (enabledConfigFilePath )
152+ err = tool .TestNginxConf (enabledConfigFilePath )
153153 if err != nil {
154154 _ = os .Remove (enabledConfigFilePath )
155155 c .JSON (http .StatusInternalServerError , gin.H {
@@ -158,7 +158,7 @@ func EnableDomain(c *gin.Context) {
158158 return
159159 }
160160
161- output := tool2 .ReloadNginx ()
161+ output := tool .ReloadNginx ()
162162
163163 if output != "" {
164164 c .JSON (http .StatusInternalServerError , gin.H {
@@ -173,7 +173,7 @@ func EnableDomain(c *gin.Context) {
173173}
174174
175175func DisableDomain (c * gin.Context ) {
176- enabledConfigFilePath := filepath .Join (tool2 .GetNginxConfPath ("sites-enabled" ), c .Param ("name" ))
176+ enabledConfigFilePath := filepath .Join (tool .GetNginxConfPath ("sites-enabled" ), c .Param ("name" ))
177177
178178 _ , err := os .Stat (enabledConfigFilePath )
179179
@@ -189,7 +189,7 @@ func DisableDomain(c *gin.Context) {
189189 return
190190 }
191191
192- output := tool2 .ReloadNginx ()
192+ output := tool .ReloadNginx ()
193193
194194 if output != "" {
195195 c .JSON (http .StatusInternalServerError , gin.H {
@@ -206,8 +206,8 @@ func DisableDomain(c *gin.Context) {
206206func DeleteDomain (c * gin.Context ) {
207207 var err error
208208 name := c .Param ("name" )
209- availablePath := filepath .Join (tool2 .GetNginxConfPath ("sites-available" ), name )
210- enabledPath := filepath .Join (tool2 .GetNginxConfPath ("sites-enabled" ), name )
209+ availablePath := filepath .Join (tool .GetNginxConfPath ("sites-available" ), name )
210+ enabledPath := filepath .Join (tool .GetNginxConfPath ("sites-enabled" ), name )
211211
212212 if _ , err = os .Stat (availablePath ); os .IsNotExist (err ) {
213213 c .JSON (http .StatusNotFound , gin.H {
0 commit comments