Sha256: d9dc2479a447ca6c384e78d68fa381ed2867723e2de659ebbd78a14b38efce3c
Contents?: true
Size: 679 Bytes
Versions: 1
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tdiary-5.3.0 | lib/tdiary/rack/valid_request_path.rb |