Sha256: 7e3a1052fc5fb6df8bfe61661238879ac6184c08644ace051379eee494c4c773

Contents?: true

Size: 679 Bytes

Versions: 37

Compression:

Stored size: 679 Bytes

Contents

module TDiary
	module Rack
		class ValidRequestPath
			def initialize( app )
				@app = app
			end

			def call( env )
				valid_paths = [
					%r{^/$},
					%r{^/index\.(rb|cgi)$},
					%r{^/([0-9\-p]+)\.html$}
				]
				valid_paths.each do |path|
					return @app.call(env) if env['PATH_INFO'].match(path)
				end

				body = "Not Found: #{env['PATH_INFO']}"
				if env["REQUEST_METHOD"] == "HEAD"
					[404, {'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s}, []]
				else
					[404, {'Content-Type' => 'text/plain'}, [body]]
				end
			end
		end
	end
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:

Version data entries

37 entries across 27 versions & 1 rubygems

Version Path
tdiary-5.0.12.1 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.11 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.10 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.9 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.8 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.7 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.6 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.3/lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/tdiary-5.0.3/lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.5 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.4 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.4 vendor/bundle/gems/tdiary-5.0.3/lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.3 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.2 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.1 lib/tdiary/rack/valid_request_path.rb