api: better routes
This commit is contained in:
parent
38875bcfac
commit
3d789c0541
|
@ -22,10 +22,6 @@ func handlePatchServer(c *gin.Context) {
|
|||
|
||||
}
|
||||
|
||||
func handlePutServer(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func handlePostServerReinstall(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
|
|
@ -21,18 +21,6 @@ func TestHandleGetIndex(t *testing.T) {
|
|||
assert.Equal(t, http.StatusOK, recorder.Code)
|
||||
}
|
||||
|
||||
func TestHandlePutConfig(t *testing.T) {
|
||||
router := gin.New()
|
||||
recorder := httptest.NewRecorder()
|
||||
|
||||
req, _ := http.NewRequest("PUT", "/", strings.NewReader("{}"))
|
||||
|
||||
router.PUT("/", handlePutConfig)
|
||||
router.ServeHTTP(recorder, req)
|
||||
|
||||
assert.Equal(t, http.StatusOK, recorder.Code)
|
||||
}
|
||||
|
||||
func TestHandlePatchConfig(t *testing.T) {
|
||||
router := gin.New()
|
||||
recorder := httptest.NewRecorder()
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
func (api *API) registerRoutes() {
|
||||
api.router.GET("/", AuthHandler(""), handleGetIndex)
|
||||
api.router.PUT("/config", AuthHandler("c:config"), handlePutConfig)
|
||||
api.router.PATCH("/config", AuthHandler("c:config"), handlePatchConfig)
|
||||
|
||||
api.registerServerRoutes()
|
||||
|
|
|
@ -2,33 +2,19 @@ package api
|
|||
|
||||
func (api *API) registerServerRoutes() {
|
||||
|
||||
// Big Picture Actions
|
||||
api.router.GET("/servers", AuthHandler("c:list"), handleGetServers)
|
||||
|
||||
api.router.POST("/servers", AuthHandler("c:create"), handlePostServers)
|
||||
api.router.DELETE("/server/:server", AuthHandler("g:server:delete"), handleDeleteServers)
|
||||
api.router.GET("/server/:server", AuthHandler("s:get"), handleGetServer)
|
||||
api.router.PATCH("/server/:server", AuthHandler("s:config"), handlePatchServer)
|
||||
|
||||
api.router.DELETE("/servers", AuthHandler("g:server:delete"), handleDeleteServers)
|
||||
|
||||
// Server Actions
|
||||
api.router.GET("/server", AuthHandler("s:get"), handleGetServer)
|
||||
|
||||
api.router.PATCH("/server", AuthHandler("s:config"), handlePatchServer)
|
||||
|
||||
api.router.PUT("/server", AuthHandler("s:config"), handlePutServer)
|
||||
|
||||
api.router.POST("/server/reinstall", AuthHandler("s:install-server"), handlePostServerReinstall)
|
||||
|
||||
api.router.POST("/server/password", AuthHandler(""), handlePostServerPassword)
|
||||
|
||||
api.router.POST("/server/rebuild", AuthHandler("g:server:rebuild"), handlePostServerRebuild)
|
||||
|
||||
api.router.PUT("/server/power", AuthHandler("s:power"), handlePutServerPower)
|
||||
|
||||
api.router.POST("/server/command", AuthHandler("s:command"), handlePostServerCommand)
|
||||
|
||||
api.router.GET("/server/log", AuthHandler("s:console"), handleGetServerLog)
|
||||
|
||||
api.router.POST("/server/suspend", AuthHandler(""), handlePostServerSuspend)
|
||||
|
||||
api.router.POST("/server/unsuspend", AuthHandler(""), handlePostServerUnsuspend)
|
||||
api.router.POST("/server/:server/reinstall", AuthHandler("s:install-server"), handlePostServerReinstall)
|
||||
api.router.POST("/server/:server/rebuild", AuthHandler("g:server:rebuild"), handlePostServerRebuild)
|
||||
api.router.POST("/server/:server/password", AuthHandler(""), handlePostServerPassword)
|
||||
api.router.POST("/server/:server/power", AuthHandler("s:power"), handlePutServerPower)
|
||||
api.router.POST("/server/:server/command", AuthHandler("s:command"), handlePostServerCommand)
|
||||
api.router.GET("/server/:server/log", AuthHandler("s:console"), handleGetServerLog)
|
||||
api.router.POST("/server/:server/suspend", AuthHandler(""), handlePostServerSuspend)
|
||||
api.router.POST("/server/:server/unsuspend", AuthHandler(""), handlePostServerUnsuspend)
|
||||
}
|
||||
|
|
|
@ -1,29 +1,20 @@
|
|||
package api
|
||||
|
||||
func (api *API) registerServerFileRoutes() {
|
||||
// TODO: better and more consistent route names.
|
||||
api.router.GET("/server/:server/files/file/:file", AuthHandler("s:files:read"), handleGetFile)
|
||||
api.router.GET("/server/:server/files/stat/:file", AuthHandler("s:files:"), handleGetFileStat)
|
||||
api.router.GET("/server/:server/files/dir/:directory", AuthHandler("s:files:get"), handleGetDirectory)
|
||||
|
||||
api.router.POST("/server/file/folder", AuthHandler("s:files:create"), handlePostFilesFolder)
|
||||
api.router.POST("/server/:server/files/dir/:directory", AuthHandler("s:files:create"), handlePostFilesFolder)
|
||||
api.router.POST("/server/:server/files/file/:file", AuthHandler("s:files:post"), handlePostFile)
|
||||
|
||||
api.router.GET("/server/directory/:directory", AuthHandler("s:files:get"), handleGetDirectory)
|
||||
api.router.POST("/server/: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("/server/: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("/server/:server/files/decompress/:file", AuthHandler("s:files:decompress"), handlePostFileDecompress)
|
||||
|
||||
api.router.POST("/server/file/copy", AuthHandler("s:files:copy"), handlePostFileCopy)
|
||||
api.router.DELETE("/server/:server/files/file/:file", AuthHandler("s:files:delete"), handleDeleteFile)
|
||||
|
||||
api.router.POST("/server/file/{move,rename}", AuthHandler("s:files:move"), handlePostFileMove)
|
||||
|
||||
api.router.POST("/server/file/delete", AuthHandler("s:files:delete"), handlePostFileDelete)
|
||||
|
||||
api.router.POST("/server/file/compress", AuthHandler("s:files:compress"), handlePostFileCompress)
|
||||
|
||||
api.router.POST("/server/file/decompress", AuthHandler("s:files:decompress"), handlePostFileDecompress)
|
||||
|
||||
api.router.GET("/server/file/stat/:file", AuthHandler("s:files:"), handleGetFileStat)
|
||||
|
||||
api.router.GET("/server/file/f/:file", AuthHandler("s:files:read"), handleGetFile)
|
||||
|
||||
api.router.POST("/server/file/save", AuthHandler("s:files:post"), handlePostFile)
|
||||
|
||||
api.router.DELETE("/server/file/f/:file", AuthHandler("s:files:delete"), handleDeleteFile)
|
||||
|
||||
api.router.GET("/server/file/download/:token", handleGetDownloadFile)
|
||||
api.router.GET("/server/:server/files/download/:token", handleGetDownloadFile)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user