616c6b1c62
Release Docker multi arch / docker (push) Has been cancelled
Test Install Script / Test Script Syntax (push) Has been cancelled
Test Install Script / Test on almalinux-10 (default) (push) Has been cancelled
Test Install Script / Test on almalinux-10 (root) (push) Has been cancelled
Test Install Script / Test on almalinux-8 (default) (push) Has been cancelled
Test Install Script / Test on almalinux-8 (root) (push) Has been cancelled
Test Install Script / Test on almalinux-9 (default) (push) Has been cancelled
Test Install Script / Test on almalinux-9 (root) (push) Has been cancelled
Test Install Script / Test on amazonlinux-2 (default) (push) Has been cancelled
Test Install Script / Test on amazonlinux-2 (root) (push) Has been cancelled
Test Install Script / Test on debian-11 (default) (push) Has been cancelled
Test Install Script / Test on debian-11 (root) (push) Has been cancelled
Test Install Script / Test on debian-12 (default) (push) Has been cancelled
Test Install Script / Test on debian-12 (root) (push) Has been cancelled
Test Install Script / Test on debian-13 (default) (push) Has been cancelled
Test Install Script / Test on debian-13 (root) (push) Has been cancelled
Test Install Script / Test on fedora-latest (default) (push) Has been cancelled
Test Install Script / Test on fedora-latest (root) (push) Has been cancelled
Test Install Script / Test on rocky-10 (default) (push) Has been cancelled
Test Install Script / Test on rocky-10 (root) (push) Has been cancelled
Test Install Script / Test on rocky-8 (default) (push) Has been cancelled
Test Install Script / Test on rocky-8 (root) (push) Has been cancelled
Test Install Script / Test on rocky-9 (default) (push) Has been cancelled
Test Install Script / Test on rocky-9 (root) (push) Has been cancelled
Test Install Script / Test on ubuntu-22.04 (default) (push) Has been cancelled
Test Install Script / Test on ubuntu-22.04 (root) (push) Has been cancelled
Test Install Script / Test on ubuntu-24.04 (default) (push) Has been cancelled
Test Install Script / Test on ubuntu-24.04 (root) (push) Has been cancelled
66 lines
1.2 KiB
Go
66 lines
1.2 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"server/rutor"
|
|
|
|
"server/dlna"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/pkg/errors"
|
|
|
|
sets "server/settings"
|
|
"server/torr"
|
|
)
|
|
|
|
// Action: get, set, def
|
|
type setsReqJS struct {
|
|
requestI
|
|
Sets *sets.BTSets `json:"sets,omitempty"`
|
|
}
|
|
|
|
// settings godoc
|
|
//
|
|
// @Summary Get / Set server settings
|
|
// @Description Allow to get or set server settings.
|
|
//
|
|
// @Tags API
|
|
//
|
|
// @Param request body setsReqJS true "Settings request. Available params for action: get, set, def"
|
|
//
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} sets.BTSets "Settings JSON or nothing. Depends on what action has been asked."
|
|
// @Router /settings [post]
|
|
func settings(c *gin.Context) {
|
|
var req setsReqJS
|
|
err := c.ShouldBindJSON(&req)
|
|
if err != nil {
|
|
c.AbortWithError(http.StatusBadRequest, err)
|
|
return
|
|
}
|
|
|
|
if req.Action == "get" {
|
|
c.JSON(200, sets.BTsets)
|
|
return
|
|
} else if req.Action == "set" {
|
|
torr.SetSettings(req.Sets)
|
|
dlna.Stop()
|
|
if req.Sets.EnableDLNA {
|
|
dlna.Start()
|
|
}
|
|
rutor.Stop()
|
|
rutor.Start()
|
|
c.Status(200)
|
|
return
|
|
} else if req.Action == "def" {
|
|
torr.SetDefSettings()
|
|
dlna.Stop()
|
|
rutor.Stop()
|
|
c.Status(200)
|
|
return
|
|
}
|
|
c.AbortWithError(http.StatusBadRequest, errors.New("action is empty"))
|
|
}
|