Sha256: ebc2131c285668a8bde12cdd59d31e5b6eaaa9e6a6de0af639fb25c03bfacc21

Contents?: true

Size: 831 Bytes

Versions: 4

Compression:

Stored size: 831 Bytes

Contents

#	This file is part of the "Utopia Framework" project, and is released under the MIT license.
#	Copyright 2010 Samuel Williams. All rights reserved.
#	See <utopia.rb> for licensing details.

require 'pathname'
require 'logger'

require 'utopia/http_status_codes'
require 'utopia/extensions/rack'

module Utopia
	LOG = Logger.new($stderr)
	LOG.level = Logger::DEBUG
	
	module Middleware
		def self.default_root(subdir = "pages")
			Pathname.new(Dir.pwd).join(subdir).cleanpath.to_s
		end
		
		def self.failure(status = 500, message = "Non-specific error")
			body = "#{HTTP_STATUS_DESCRIPTIONS[status] || status.to_s}: #{message}"
			
			return [status, {
				"Content-Type" => "text/plain",
				"Content-Length" => body.size.to_s,
				"X-Cascade" => "pass"
			}, [body]]
		end
	end
end

require 'utopia/path'
require 'utopia/tag'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
utopia-0.10.0 lib/utopia/middleware.rb
utopia-0.9.61 lib/utopia/middleware.rb
utopia-0.9.60 lib/utopia/middleware.rb
utopia-0.9.59 lib/utopia/middleware.rb