mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-21 06:26:10 +05:00
refactor and update
This commit is contained in:
@@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"server/torr"
|
||||
"server/version"
|
||||
)
|
||||
|
||||
@@ -10,13 +9,7 @@ type requestI struct {
|
||||
Action string `json:"action,omitempty"`
|
||||
}
|
||||
|
||||
type responseI struct {
|
||||
}
|
||||
|
||||
var bts *torr.BTServer
|
||||
|
||||
func SetupRouteApi(route *gin.Engine, serv *torr.BTServer) {
|
||||
bts = serv
|
||||
func SetupRoute(route *gin.Engine) {
|
||||
route.GET("/echo", echo)
|
||||
|
||||
route.POST("/settings", settings)
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
settings2 "server/settings"
|
||||
sets "server/settings"
|
||||
)
|
||||
|
||||
//Action: get, set
|
||||
type setsReqJS struct {
|
||||
requestI
|
||||
Sets *settings2.BTSets `json:"sets,omitempty"`
|
||||
Sets *sets.BTSets `json:"sets,omitempty"`
|
||||
}
|
||||
|
||||
func settings(c *gin.Context) {
|
||||
@@ -23,11 +23,11 @@ func settings(c *gin.Context) {
|
||||
}
|
||||
|
||||
if req.Action == "get" {
|
||||
c.JSON(200, settings2.BTsets)
|
||||
c.JSON(200, sets.BTsets)
|
||||
return
|
||||
}
|
||||
if req.Action == "set" {
|
||||
settings2.SetBTSets(req.Sets)
|
||||
sets.SetBTSets(req.Sets)
|
||||
c.Status(200)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user