mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
refactor and to go mod
This commit is contained in:
37
server/web/api/settings.go
Normal file
37
server/web/api/settings.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
sets "server/settings"
|
||||
"server/torr"
|
||||
)
|
||||
|
||||
//Action: get, set
|
||||
type setsReqJS struct {
|
||||
requestI
|
||||
Sets *sets.BTSets `json:"sets,omitempty"`
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
if req.Action == "set" {
|
||||
torr.SetSettings(req.Sets)
|
||||
c.Status(200)
|
||||
return
|
||||
}
|
||||
c.AbortWithError(http.StatusBadRequest, errors.New("action is empty"))
|
||||
}
|
||||
Reference in New Issue
Block a user