Attempting to get post requests working.

This commit is contained in:
Travis
2013-04-02 15:45:04 -07:00
parent 01939a0744
commit 3cdee540bf
5 changed files with 29 additions and 20 deletions

View File

@@ -10,19 +10,19 @@ The idea here is that IronWorker backend can tell the router that it started a p
This is just a simple prototype. To get to production would need:
- Routing table in central storage (mongo or IronCache) so all routers can write to it and read to get updates.
- Update routing table from central store every X minutes.
- Remove failed routes and start new workers if it failed.
- Expire routes after 55 minutes or so.
- Ability to start new workers if none are running.
- Ability to always keep a minimum number running at all times, like at least one (or not if on free account?).
- Ability to start new workers based on some auto scaling scheme.
- Ability to start new workers based on some auto scaling scheme.
- Authentication (same as always).
## Testing for reals
## Testing for reals on staging
- start router.go on remote server (there's a test project on SD already: http://www.simpledeployer.com/projects/ea129e74-52fa-11e2-a91a-12313d008ea2/servers)
- go build ./src/router; sudo ./router
- start router.go on remote server (there's a test project on SD already:
- http://www.simpledeployer.com/projects/ea129e74-52fa-11e2-a91a-12313d008ea2/servers
- go build ./src/router; sudo ./router
- iron_worker upload -e staging --project-id 51034bc3c2e603384b00a092 --host routertest.irondns.info sinatra
- visit http://routertest.iron.io (or ruby client.rb)
- BOOM!
## Deploying to production
- just deploy as normal from SD project

View File

@@ -1,11 +1,14 @@
require 'rest'
Rest.logger.level = Logger::DEBUG
rest = Rest::Client.new
rest.logger.level = Logger::DEBUG
response = rest.get(
#"http://localhost:8080/"
"http://routertest.irondns.info/"
)
base_url = "http://routertest.irondns.info/"
#"http://localhost:8080/"
response = rest.get(base_url)
puts "body:"
puts response.body
# test post
rest.post(base_url, :form_data=>{:x=>1, :y=>"a"})

View File

@@ -1,8 +1,8 @@
{
"iron": {
"cache_host": "staging-cache.iron.io",
"project_id": "510d3381c2e603648d0005f5",
"token": "liILas32ParkPtDfK9ztjWP_RI0",
"project_id": "515b5da6c731ff1e690008aa",
"token": "TXT6wq-pfkHSTvWbaJ_wPUmqVnE",
"super_token": "Lfvq3ev2DfyRebBn07hXZEvH3pQ",
"worker_host": "staging-worker.iron.io"
},

View File

@@ -126,11 +126,11 @@ func main() {
s := r.Host("router.irondns.info").Subrouter()
s.Handle("/1/projects/{project_id:[0-9a-fA-F]{24}}/register", &common.AuthHandler{&Register{}, ironAuth})
s.HandleFunc("/ping", Ping)
s.HandleFunc("/ping", Ping) // for ELB health check
s.Handle("/addworker", &WorkerHandler{})
s.HandleFunc("/", Ping)
r.HandleFunc("/ping", Ping) // for ELB health check
// Now for everyone else:
r.HandleFunc("/", ProxyFunc)
http.Handle("/", r)

View File

@@ -8,8 +8,14 @@ port = ENV['PORT'].to_i
puts "STARTING SINATRA on port #{port}"
my_app = Sinatra.new do
set :port, port
post('/somepost') do
puts "in somepost"
p params
end
get('/pingsinatra') { "pong" }
get('/') { "hi" }
get('/*') { "you passed in #{params[:splat].inspect}" }
# get('/*') { "you passed in #{params[:splat].inspect}" }
end
my_app.run!