refactor and update

This commit is contained in:
YouROK
2020-11-11 17:01:14 +03:00
parent b4a20760cc
commit 0d9f68c3c8
11 changed files with 258 additions and 13 deletions

View File

@@ -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)

View File

@@ -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
}