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.2.4 lib/tdiary/rack/valid_request_path.rb
tdiary-5.2.3 lib/tdiary/rack/valid_request_path.rb
tdiary-5.2.2 lib/tdiary/rack/valid_request_path.rb
tdiary-5.2.1 lib/tdiary/rack/valid_request_path.rb
tdiary-5.2.0 lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.7 lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.6 lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.5 lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.4 lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.3 lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.2 lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.1 lib/tdiary/rack/valid_request_path.rb
tdiary-5.1.0 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.14 lib/tdiary/rack/valid_request_path.rb
tdiary-5.0.13 lib/tdiary/rack/valid_request_path.rb