Sha256: ff42ca7c370d6beb95fb61ec8cba026c1bd49277da1a1b79cc4986670a290877
Contents?: true
Size: 699 Bytes
Versions: 1
Compression:
Stored size: 699 Bytes
Contents
require 'sinatra/base' module Sinatra module Presence def self.registered(app) app.set :local_authority, 'http://127.0.0.1:9292' # http://en.wikipedia.org/wiki/URI_scheme app.before do if(request.cookies["local_url"].nil?) new_url = request.url.gsub("#{request.scheme}://#{request.host_with_port}", "#{settings.local_authority}").gsub("/local", "") response.set_cookie(:local_url, value: new_url, expires: Time.now + 600) end end app.get '/local' do new_url = request.url.gsub("#{request.host_with_port}", "#{settings.local_authority}").gsub("/local", "") redirect to(new_url) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinatra-presence-0.0.2 | lib/sinatra/presence.rb |