mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
add shutdown
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
sets "server/settings"
|
||||
"server/torr"
|
||||
"server/version"
|
||||
)
|
||||
|
||||
@@ -11,6 +16,7 @@ type requestI struct {
|
||||
|
||||
func SetupRoute(route *gin.Engine) {
|
||||
route.GET("/echo", echo)
|
||||
route.GET("/shutdown", shutdown)
|
||||
|
||||
route.POST("/settings", settings)
|
||||
|
||||
@@ -29,3 +35,15 @@ func SetupRoute(route *gin.Engine) {
|
||||
func echo(c *gin.Context) {
|
||||
c.String(200, "%v", version.Version)
|
||||
}
|
||||
|
||||
func shutdown(c *gin.Context) {
|
||||
if sets.IsReadOnly() {
|
||||
c.Status(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
c.Status(200)
|
||||
go func() {
|
||||
time.Sleep(1000)
|
||||
torr.Shutdown()
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user