Sha256: 46666beffefbd2683cf8ddfff7c5e2bd1bb356711d1413e4bc7a4977861c1e43
Contents?: true
Size: 1.97 KB
Versions: 5
Compression:
Stored size: 1.97 KB
Contents
require 'deas' class Deas::Server root File.expand_path("..", __FILE__) log_file_path = File.expand_path("../../../log/test.log", __FILE__) logger Logger.new(File.open(log_file_path, 'w')) verbose_logging true error do |exception| case exception when Sinatra::NotFound halt 404, "Couldn't be found" when Exception halt 500, "Oops, something went wrong" end end get '/show', 'ShowHandler' get '/halt', 'HaltHandler' get '/error', 'ErrorHandler' get '/with_layout', 'WithLayoutHandler' get '/alt_with_layout', 'AlternateWithLayoutHandler' get '/redirect', 'RedirectHandler' get '/redirect_to', 'RedirectToHandler' post '/session', 'SetSessionHandler' get '/session', 'UseSessionHandler' end class ShowHandler include Deas::ViewHandler attr_reader :message def init! @message = params['message'] end def run! render 'show' end end class HaltHandler include Deas::ViewHandler def init! halt params['with'].to_i end end class ErrorHandler include Deas::ViewHandler def run! raise 'test' end end class WithLayoutHandler include Deas::ViewHandler layouts 'layout1', 'layout2', 'layout3' def run! render 'with_layout' end end class AlternateWithLayoutHandler include Deas::ViewHandler def run! render 'layout1' do render 'layout2' do render 'layout3' do render 'with_layout' end end end end end class RedirectHandler include Deas::ViewHandler def run! redirect 'http://google.com', 'wrong place, buddy' end end class RedirectToHandler include Deas::ViewHandler def run! redirect_to '/somewhere' end end class SetSessionHandler include Deas::ViewHandler def run! session[:secret] = 'session_secret' redirect_to '/session' end end class UseSessionHandler include Deas::ViewHandler def run! session[:secret] end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
deas-0.6.0 | test/support/routes.rb |
deas-0.5.0 | test/support/routes.rb |
deas-0.4.1 | test/support/routes.rb |
deas-0.4.0 | test/support/routes.rb |
deas-0.3.0 | test/support/routes.rb |