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:
55
server/web/api/route.go
Normal file
55
server/web/api/route.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
sets "server/settings"
|
||||
"server/torr"
|
||||
"server/version"
|
||||
)
|
||||
|
||||
type requestI struct {
|
||||
Action string `json:"action,omitempty"`
|
||||
}
|
||||
|
||||
func SetupRoute(route *gin.Engine) {
|
||||
route.GET("/echo", echo)
|
||||
route.GET("/shutdown", shutdown)
|
||||
|
||||
route.POST("/settings", settings)
|
||||
|
||||
route.POST("/torrents", torrents)
|
||||
route.POST("/torrent/upload", torrentUpload)
|
||||
|
||||
route.POST("/cache", cache)
|
||||
|
||||
route.HEAD("/stream", stream)
|
||||
route.HEAD("/stream/*fname", stream)
|
||||
|
||||
route.GET("/stream", stream)
|
||||
route.GET("/stream/*fname", stream)
|
||||
|
||||
route.POST("/viewed", viewed)
|
||||
|
||||
route.GET("/playlistall/all.m3u", allPlayList)
|
||||
route.GET("/playlist", playList)
|
||||
route.GET("/playlist/*fname", playList)
|
||||
}
|
||||
|
||||
func echo(c *gin.Context) {
|
||||
c.String(200, "%v", version.Version)
|
||||
}
|
||||
|
||||
func shutdown(c *gin.Context) {
|
||||
if sets.ReadOnly {
|
||||
c.Status(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
c.Status(200)
|
||||
go func() {
|
||||
time.Sleep(1000)
|
||||
torr.Shutdown()
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user