Sha256: e753a0433dd27fb79186e6e58a3af7b0c6487ea2059ddcce25fd8cdbb6273d71
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
require ::File.dirname(__FILE__) + '/cerberus' use Rack::Session::Cookie, :secret => 'change_me' F = ::File map '/' do run lambda {|env| body = <<-EOB.strip <html> <head> <title>Cerberus</title> </head> <body>This page is public, so you can see it. But what happens if you want to see a <a href='/secret'>Secret Page</a>? Nevertheless, I can give you access:<br /><br /> Login: <b>mario</b><br />Pass: <b>bros</b> </body> </html> EOB [200, {'Content-Type' => 'text/html'}, [body]] } end map '/secret' do use Cerberus, {:company_name => 'Nintendo', :fg_color => 'red', :css_location => '/css'} do |login,pass| [login,pass]==['mario','bros'] end run lambda {|env| [200, {'Content-Type' => 'text/plain'}, ['Welcome back Mario. Your Credit Card number is: 9292']] } end map '/css' do run lambda {|env| path = F.expand_path('./example.css') [200, {'Content-Type' => 'text/css', "Last-Modified" => F.mtime(path).httpdate, "Content-Length" => F.size?(path).to_s}, [F.read(path)]] } end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rack-cerberus-0.3.1 | example.ru |
rack-cerberus-0.3.0 | example.ru |
rack-cerberus-0.2.0 | example.ru |