File: echo_env.rb

package info (click to toggle)
ruby-rack-mobile-detect 0.4.0-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 124 kB
  • sloc: ruby: 296; makefile: 4
file content (20 lines) | stat: -rw-r--r-- 549 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'rubygems'
require 'sinatra'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'rack/mobile-detect'

use Rack::MobileDetect

# Very simple sinatra app that allows debugging of the headers with
# Rack::MobileDetect. Also useful for looking at various mobile phone
# headers.
get '/' do
  content_type 'text/plain'
  env_string = env.sort.map{ |v| v.join(': ') }.join("\n") + "\n"
  # Print to log if debug is passed, i.e.:
  # http://localhost:4567/?debug
  puts env_string if params.key?('debug')
  env_string
end