print body for debugging.

This commit is contained in:
Travis
2013-01-16 00:34:53 -08:00
parent d80db6abec
commit 3da34ef5a5
2 changed files with 12 additions and 20 deletions

View File

@@ -1,38 +1,26 @@
require 'rest'
require 'uber_config'
@config = UberConfig.load('config_development.yml')
@config = UberConfig.load(file: 'config_development.json')
rest = Rest::Client.new
rest.logger.level = Logger::DEBUG
project_id = @config[:project_id]
token = @config[:token]
project_id = @config[:iron][:project_id]
token = @config[:iron][:token]
# host name
host_name = @config[:host_name] || "routertest.irondns.info"
host_name = @config[:iron][:host_name] || "routertest.irondns.info"
# which worker to run
code_name = @config[:code_name] || "sinatra"
code_name = @config[:iron][:code_name] || "sinatra"
response = rest.post(
# "http://localhost:8080/",
"http://router.irondns.info/?project_id=#{project_id}&token=#{token}&code_name=#{code_name}",
headers: {"Iron-Router"=>"register"},
body: {"host"=>host_name, "code"=>code_name)
puts "body:"
body: {"host"=>host_name, "code"=>code_name}
)
puts "response body:"
puts response.body
puts "\n\n=======\n\n"
STDOUT.flush
# Now we start the actual worker
##################################################################3
ENV['PORT'] = port.to_s # for sinatra
my_app = Sinatra.new do
set :port, port
get('/') { "hi" }
get('/*') { "you passed in #{params[:splat].inspect}" }
end
my_app.run!

View File

@@ -24,6 +24,7 @@ import (
"time"
"runtime"
"flag"
"io/ioutil"
)
var config struct {
@@ -186,6 +187,9 @@ func ProxyFunc(w http.ResponseWriter, req *http.Request) {
func AddWorker(w http.ResponseWriter, req *http.Request) {
log.Println("AddWorker called!")
s, err := ioutil.ReadAll(req.Body)
fmt.Println("req.body:", err, s)
// get project id and token
projectId := req.FormValue("project_id")
token := req.FormValue("token")