fix some merge fails

This commit is contained in:
Jakob Schrettenbrunner 2017-10-09 21:01:24 +02:00
parent 659dbcb8c3
commit 72ac95267b
5 changed files with 28 additions and 31 deletions

View File

@ -21,15 +21,12 @@ func NewAPI() InternalAPI {
// Configure the API and begin listening on the configured IP and Port. // Configure the API and begin listening on the configured IP and Port.
func (api *InternalAPI) Listen() { func (api *InternalAPI) Listen() {
listener := fmt.Sprintf("%s:%d", viper.GetString(config.APIHost), viper.GetInt(config.APIPort))
if !viper.GetBool(config.Debug) { if !viper.GetBool(config.Debug) {
gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
} }
api.router = gin.Default() api.router = gin.Default()
api.router.RedirectTrailingSlash = false api.router.RedirectTrailingSlash = false
api.RegisterRoutes()
api.router.Use(func(c *gin.Context) { api.router.Use(func(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", "*") c.Header("Access-Control-Allow-Origin", "*")
@ -40,7 +37,7 @@ func (api *InternalAPI) Listen() {
c.Header("Access-Control-Allow-Headers", "X-Access-Token") c.Header("Access-Control-Allow-Headers", "X-Access-Token")
}) })
api.registerRoutes() api.RegisterRoutes()
listenString := fmt.Sprintf("%s:%d", viper.GetString(config.APIHost), viper.GetInt(config.APIPort)) listenString := fmt.Sprintf("%s:%d", viper.GetString(config.APIHost), viper.GetInt(config.APIPort))

View File

@ -104,7 +104,7 @@ type incomingConfiguration struct {
} }
// handlePatchConfig handles PATCH /config // handlePatchConfig handles PATCH /config
func handlePatchConfig(c *gin.Context) { func PatchConfiguration(c *gin.Context) {
// reqBody, err := ioutil.ReadAll(c.Request.Body) // reqBody, err := ioutil.ReadAll(c.Request.Body)
// if err != nil { // if err != nil {
// log.WithError(err).Error("Failed to read input.") // log.WithError(err).Error("Failed to read input.")

View File

@ -5,7 +5,7 @@ func (api *InternalAPI) RegisterRoutes() {
// the existing Nodejs Daemon API. // the existing Nodejs Daemon API.
v1 := api.router.Group("/v1") v1 := api.router.Group("/v1")
{ {
v1.GET("/", AuthHandler(""), GetIndex) v1.GET("", AuthHandler(""), GetIndex)
v1.PATCH("/config", AuthHandler("c:config"), PatchConfiguration) v1.PATCH("/config", AuthHandler("c:config"), PatchConfiguration)
v1.GET("/servers", AuthHandler("c:list"), handleGetServers) v1.GET("/servers", AuthHandler("c:list"), handleGetServers)
@ -13,9 +13,9 @@ func (api *InternalAPI) RegisterRoutes() {
v1ServerRoutes := v1.Group("/servers/:server") v1ServerRoutes := v1.Group("/servers/:server")
{ {
v1ServerRoutes.GET("/", AuthHandler("s:get"), handleGetServer) v1ServerRoutes.GET("", AuthHandler("s:get"), handleGetServer)
v1ServerRoutes.PATCH("/", AuthHandler("s:config"), handlePatchServer) v1ServerRoutes.PATCH("", AuthHandler("s:config"), handlePatchServer)
v1ServerRoutes.DELETE("/", AuthHandler("g:server:delete"), handleDeleteServer) v1ServerRoutes.DELETE("", AuthHandler("g:server:delete"), handleDeleteServer)
v1ServerRoutes.POST("/reinstall", AuthHandler("s:install-server"), handlePostServerReinstall) v1ServerRoutes.POST("/reinstall", AuthHandler("s:install-server"), handlePostServerReinstall)
v1ServerRoutes.POST("/rebuild", AuthHandler("g:server:rebuild"), handlePostServerRebuild) v1ServerRoutes.POST("/rebuild", AuthHandler("g:server:rebuild"), handlePostServerRebuild)
v1ServerRoutes.POST("/password", AuthHandler(""), handlePostServerPassword) v1ServerRoutes.POST("/password", AuthHandler(""), handlePostServerPassword)
@ -26,24 +26,24 @@ func (api *InternalAPI) RegisterRoutes() {
v1ServerRoutes.POST("/unsuspend", AuthHandler(""), handlePostServerUnsuspend) v1ServerRoutes.POST("/unsuspend", AuthHandler(""), handlePostServerUnsuspend)
} }
v1ServerFileRoutes := v1.Group("/servers/:server/files") //v1ServerFileRoutes := v1.Group("/servers/:server/files")
{ //{
v1ServerFileRoutes.GET("/file/:file", AuthHandler("s:files:read"), handleGetFile) // v1ServerFileRoutes.GET("/file/:file", AuthHandler("s:files:read"), handleGetFile)
v1ServerFileRoutes.GET("/stat/:file", AuthHandler("s:files:"), handleGetFileStat) // v1ServerFileRoutes.GET("/stat/:file", AuthHandler("s:files:"), handleGetFileStat)
v1ServerFileRoutes.GET("/dir/:directory", AuthHandler("s:files:get"), handleGetDirectory) // v1ServerFileRoutes.GET("/dir/:directory", AuthHandler("s:files:get"), handleGetDirectory)
//
v1ServerFileRoutes.POST("/dir/:directory", AuthHandler("s:files:create"), handlePostFilesFolder) // v1ServerFileRoutes.POST("/dir/:directory", AuthHandler("s:files:create"), handlePostFilesFolder)
v1ServerFileRoutes.POST("/file/:file", AuthHandler("s:files:post"), handlePostFile) // v1ServerFileRoutes.POST("/file/:file", AuthHandler("s:files:post"), handlePostFile)
//
v1ServerFileRoutes.POST("/copy/:file", AuthHandler("s:files:copy"), handlePostFileCopy) // v1ServerFileRoutes.POST("/copy/:file", AuthHandler("s:files:copy"), handlePostFileCopy)
v1ServerFileRoutes.POST("/move/:file", AuthHandler("s:files:move"), handlePostFileMove) // v1ServerFileRoutes.POST("/move/:file", AuthHandler("s:files:move"), handlePostFileMove)
v1ServerFileRoutes.POST("/rename/:file", AuthHandler("s:files:move"), handlePostFileMove) // v1ServerFileRoutes.POST("/rename/:file", AuthHandler("s:files:move"), handlePostFileMove)
v1ServerFileRoutes.POST("/compress/:file", AuthHandler("s:files:compress"), handlePostFileCompress) // v1ServerFileRoutes.POST("/compress/:file", AuthHandler("s:files:compress"), handlePostFileCompress)
v1ServerFileRoutes.POST("/decompress/:file", AuthHandler("s:files:decompress"), handlePostFileDecompress) // v1ServerFileRoutes.POST("/decompress/:file", AuthHandler("s:files:decompress"), handlePostFileDecompress)
//
v1ServerFileRoutes.DELETE("/file/:file", AuthHandler("s:files:delete"), handleDeleteFile) // v1ServerFileRoutes.DELETE("/file/:file", AuthHandler("s:files:delete"), handleDeleteFile)
//
v1ServerFileRoutes.GET("/download/:token", handleGetDownloadFile) // v1ServerFileRoutes.GET("/download/:token", handleGetDownloadFile)
} //}
} }
} }

View File

@ -35,12 +35,12 @@ func Execute() {
} }
func run(cmd *cobra.Command, args []string) { func run(cmd *cobra.Command, args []string) {
tools.InitLogging() utils.InitLogging()
log.Info("Loading configuration...") log.Info("Loading configuration...")
if err := config.LoadConfiguration(configPath); err != nil { if err := config.LoadConfiguration(configPath); err != nil {
log.WithError(err).Fatal("Failed to find configuration file") log.WithError(err).Fatal("Failed to find configuration file")
} }
tools.ConfigureLogging() utils.ConfigureLogging()
log.Info(` ____`) log.Info(` ____`)
log.Info(`__ Pterodactyl _____/___/_______ _______ ______`) log.Info(`__ Pterodactyl _____/___/_______ _______ ______`)

View File

@ -1,4 +1,4 @@
package tools package utils
import ( import (
"os" "os"