Class: Mamemose::Server
Instance Method Summary collapse
- #file(filename) ⇒ Object
-
#initialize(port) ⇒ Server
constructor
A new instance of Server.
- #server ⇒ Object
- #start ⇒ Object
Methods included from HTML
#footer_html, #header_html, #link_list, #search_form
Methods included from Path
#docpath, #escape, #escaped_basename, #fullpath, #showpath, #uri
Constructor Details
Instance Method Details
#file(filename) ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/mamemose.rb', line 71 def file(filename) @mamemose.mount_proc('/') do |req, res| res['Cache-Control'] = 'no-cache, no-store, must-revalidate' res['Pragma'] = 'no-cache' res['Expires'] = '0' res = req_file(File.absolute_path(filename), res, true) res.content_type = CONTENT_TYPE end start end |
#server ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mamemose.rb', line 51 def server @mamemose.mount_proc('/') do |req, res| res['Cache-Control'] = 'no-cache, no-store, must-revalidate' res['Pragma'] = 'no-cache' res['Expires'] = '0' p fullpath(req.path) if req.path =~ /^\/search/ res = req_search(req, res) elsif File.directory?(fullpath(req.path)) res = req_index(req, res) elsif File.exists?(fullpath(req.path)) res = req_file(fullpath(req.path), res, false) else res.status = WEBrick::HTTPStatus::RC_NOT_FOUND end end start end |
#start ⇒ Object
47 48 49 |
# File 'lib/mamemose.rb', line 47 def start @mamemose.start end |