Sha256: 37ccec3bd05ebcf5eae719c88ff5e4ba1b2d45b17a37a352662e54b18baf1ec4
Contents?: true
Size: 770 Bytes
Versions: 124
Compression:
Stored size: 770 Bytes
Contents
# Example usage: # # hello.cgi: # # require 'ruby2js/cgi' # __END__ # alert 'Hello World!' # # Using an optional filter: # # require 'ruby2js/filter/functions' require 'ruby2js' at_exit do status = 200 headers = [] begin require 'time' modtime = File.stat($0).mtime.rfc2822 headers << "Last-Modified: #{modtime}\r\n" status = 304 if ENV['HTTP_IF_MODIFIED_SINCE'] == modtime rescue end if status == 200 require 'digest/md5' js = Ruby2JS.convert(DATA.read) etag = Digest::MD5.hexdigest(js).inspect headers << "Etag: #{etag}\r\n" status = 304 if ENV['HTTP_IF_NONE_MATCH'] == etag end if status == 200 print "#{headers.join}\r\n#{js}" else print "Status: 304 Not Modified\r\n\r\n" end end
Version data entries
124 entries across 124 versions & 1 rubygems