File: redirecting.ru

package info (click to toggle)
ruby-excon 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,240 kB
  • sloc: ruby: 7,970; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 367 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'sinatra'
require 'json'

class App < Sinatra::Base
  set :environment, :production
  enable :dump_errors

  post('/first') do
    redirect "/second"
  end

  get('/second') do
    post_body = request.body.read
    if post_body == "" && request.env["CONTENT_LENGTH"].nil?
      "ok"
    else
      JSON.pretty_generate(request.env)
    end
  end
end

run App