api: improve routes

This commit is contained in:
Jakob Schrettenbrunner 2017-08-31 23:57:33 +02:00
parent ef28b61136
commit 7b9c67d508
3 changed files with 23 additions and 31 deletions

View File

@ -1,9 +1,5 @@
package api package api
import (
"github.com/gin-gonic/gin"
)
func (api *API) registerRoutes() { func (api *API) registerRoutes() {
api.router.GET("/", AuthHandler(""), handleGetIndex) api.router.GET("/", AuthHandler(""), handleGetIndex)
api.router.PATCH("/config", AuthHandler("c:config"), handlePatchConfig) api.router.PATCH("/config", AuthHandler("c:config"), handlePatchConfig)
@ -11,7 +7,3 @@ func (api *API) registerRoutes() {
api.registerServerRoutes() api.registerServerRoutes()
api.registerServerFileRoutes() api.registerServerFileRoutes()
} }
func handle(c *gin.Context) {
}

View File

@ -5,16 +5,16 @@ func (api *API) registerServerRoutes() {
api.router.GET("/servers", AuthHandler("c:list"), handleGetServers) api.router.GET("/servers", AuthHandler("c:list"), handleGetServers)
api.router.POST("/servers", AuthHandler("c:create"), handlePostServers) api.router.POST("/servers", AuthHandler("c:create"), handlePostServers)
api.router.DELETE("/server/:server", AuthHandler("g:server:delete"), handleDeleteServers) api.router.GET("/servers/:server", AuthHandler("s:get"), handleGetServer)
api.router.GET("/server/:server", AuthHandler("s:get"), handleGetServer) api.router.PATCH("/servers/:server", AuthHandler("s:config"), handlePatchServer)
api.router.PATCH("/server/:server", AuthHandler("s:config"), handlePatchServer) api.router.DELETE("/servers/:server", AuthHandler("g:server:delete"), handleDeleteServer)
api.router.POST("/server/:server/reinstall", AuthHandler("s:install-server"), handlePostServerReinstall) api.router.POST("/servers/:server/reinstall", AuthHandler("s:install-server"), handlePostServerReinstall)
api.router.POST("/server/:server/rebuild", AuthHandler("g:server:rebuild"), handlePostServerRebuild) api.router.POST("/servers/:server/rebuild", AuthHandler("g:server:rebuild"), handlePostServerRebuild)
api.router.POST("/server/:server/password", AuthHandler(""), handlePostServerPassword) api.router.POST("/servers/:server/password", AuthHandler(""), handlePostServerPassword)
api.router.POST("/server/:server/power", AuthHandler("s:power"), handlePutServerPower) api.router.POST("/servers/:server/power", AuthHandler("s:power"), handlePutServerPower)
api.router.POST("/server/:server/command", AuthHandler("s:command"), handlePostServerCommand) api.router.POST("/servers/:server/command", AuthHandler("s:command"), handlePostServerCommand)
api.router.GET("/server/:server/log", AuthHandler("s:console"), handleGetServerLog) api.router.GET("/servers/:server/log", AuthHandler("s:console"), handleGetServerLog)
api.router.POST("/server/:server/suspend", AuthHandler(""), handlePostServerSuspend) api.router.POST("/servers/:server/suspend", AuthHandler(""), handlePostServerSuspend)
api.router.POST("/server/:server/unsuspend", AuthHandler(""), handlePostServerUnsuspend) api.router.POST("/servers/:server/unsuspend", AuthHandler(""), handlePostServerUnsuspend)
} }

View File

@ -1,20 +1,20 @@
package api package api
func (api *API) registerServerFileRoutes() { func (api *API) registerServerFileRoutes() {
api.router.GET("/server/:server/files/file/:file", AuthHandler("s:files:read"), handleGetFile) api.router.GET("/servers/:server/files/file/:file", AuthHandler("s:files:read"), handleGetFile)
api.router.GET("/server/:server/files/stat/:file", AuthHandler("s:files:"), handleGetFileStat) api.router.GET("/servers/:server/files/stat/:file", AuthHandler("s:files:"), handleGetFileStat)
api.router.GET("/server/:server/files/dir/:directory", AuthHandler("s:files:get"), handleGetDirectory) api.router.GET("/servers/:server/files/dir/:directory", AuthHandler("s:files:get"), handleGetDirectory)
api.router.POST("/server/:server/files/dir/:directory", AuthHandler("s:files:create"), handlePostFilesFolder) api.router.POST("/servers/:server/files/dir/:directory", AuthHandler("s:files:create"), handlePostFilesFolder)
api.router.POST("/server/:server/files/file/:file", AuthHandler("s:files:post"), handlePostFile) api.router.POST("/servers/:server/files/file/:file", AuthHandler("s:files:post"), handlePostFile)
api.router.POST("/server/:server/files/copy/:file", AuthHandler("s:files:copy"), handlePostFileCopy) api.router.POST("/servers/:server/files/copy/:file", AuthHandler("s:files:copy"), handlePostFileCopy)
api.router.POST("/server/:server/files/move/:file", AuthHandler("s:files:move"), handlePostFileMove) api.router.POST("/servers/:server/files/move/:file", AuthHandler("s:files:move"), handlePostFileMove)
api.router.POST("/server/:server/files/rename/:file", AuthHandler("s:files:move"), handlePostFileMove) api.router.POST("/servers/:server/files/rename/:file", AuthHandler("s:files:move"), handlePostFileMove)
api.router.POST("/server/:server/files/compress/:file", AuthHandler("s:files:compress"), handlePostFileCompress) api.router.POST("/servers/:server/files/compress/:file", AuthHandler("s:files:compress"), handlePostFileCompress)
api.router.POST("/server/:server/files/decompress/:file", AuthHandler("s:files:decompress"), handlePostFileDecompress) api.router.POST("/servers/:server/files/decompress/:file", AuthHandler("s:files:decompress"), handlePostFileDecompress)
api.router.DELETE("/server/:server/files/file/:file", AuthHandler("s:files:delete"), handleDeleteFile) api.router.DELETE("/servers/:server/files/file/:file", AuthHandler("s:files:delete"), handleDeleteFile)
api.router.GET("/server/:server/files/download/:token", handleGetDownloadFile) api.router.GET("/servers/:server/files/download/:token", handleGetDownloadFile)
} }