Skip to content
Permalink
Browse files

github issue #98, add minecraft server commands

  • Loading branch information...
Raekye committed Aug 15, 2019
1 parent aa4f3bb commit a746b2a21f0304b1c6352f01ba2ace9eb29bbfea
Showing with 16 additions and 0 deletions.
  1. +15 −0 app/controllers/servers_controller.rb
  2. +1 −0 config/routes.rb
@@ -7,6 +7,7 @@ class ServersController < ApplicationController
:api_pause,
:api_resume,
:api_backup,
:api_exec,
]
before_action :authenticate_user!, except: @@api_endpoints
skip_before_action :verify_authenticity_token, only: @@api_endpoints
@@ -372,6 +373,20 @@ def api_backup
}
end

def api_exec
server = Server.where(id: params[:id], api_key: params[:key])
if server.length == 0
render json: {
error: 'Not found',
}, status: 404
return
end
err = server[0].minecraft.exec(server[0].user, params[:command])
return render json: {
error: err,
}
end

def show_digital_ocean_droplets
@do_droplets = current_user.digital_ocean_droplets
render layout: nil
@@ -96,6 +96,7 @@
post 'api/:key/pause', to: 'servers#api_pause', as: :api_pause
post 'api/:key/resume', to: 'servers#api_resume', as: :api_resume
post 'api/:key/backup', to: 'servers#api_backup', as: :api_backup
post 'api/:key/exec', to: 'servers#api_exec', as: :api_exec
end
end

0 comments on commit a746b2a

Please sign in to comment.
You can’t perform that action at this time.