feat(wip): docker ui only

This commit is contained in:
Jacky 2025-04-20 22:02:29 +08:00
parent c62fd25b2e
commit d4a4ed1e1c
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
43 changed files with 1269 additions and 372 deletions

View file

@ -5,24 +5,36 @@ import (
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/gin-gonic/gin"
"github.com/uozi-tech/cosy"
)
// Reload reloads the nginx
func Reload(c *gin.Context) {
output := nginx.Reload()
output, err := nginx.Reload()
if err != nil {
cosy.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": output,
"level": nginx.GetLogLevel(output),
})
}
func Test(c *gin.Context) {
output := nginx.TestConf()
// TestConfig tests the nginx config
func TestConfig(c *gin.Context) {
output, err := nginx.TestConfig()
if err != nil {
cosy.ErrHandler(c, err)
return
}
c.JSON(http.StatusOK, gin.H{
"message": output,
"level": nginx.GetLogLevel(output),
})
}
// Restart restarts the nginx
func Restart(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "ok",
@ -30,8 +42,13 @@ func Restart(c *gin.Context) {
go nginx.Restart()
}
// Status returns the status of the nginx
func Status(c *gin.Context) {
lastOutput := nginx.GetLastOutput()
lastOutput, err := nginx.GetLastOutput()
if err != nil {
cosy.ErrHandler(c, err)
return
}
running := nginx.IsNginxRunning()