Class: Luna::Server
- Inherits:
-
Async::HTTP::Server
- Object
- Async::HTTP::Server
- Luna::Server
- Defined in:
- lib/luna/server.rb
Overview
HTTP server hosting a middleware stack for static content.
Class Method Summary collapse
-
.middleware(root: Dir.pwd, verbose: false, markdown: true, index: "index.html", directory_listing: true) ⇒ Object
Build a middleware for serving static files with optional markdown and logging.
Class Method Details
.middleware(root: Dir.pwd, verbose: false, markdown: true, index: "index.html", directory_listing: true) ⇒ Object
Build a middleware for serving static files with optional markdown and logging.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/luna/server.rb', line 23 def self.middleware(root: Dir.pwd, verbose: false, markdown: true, index: "index.html", directory_listing: true) ::Protocol::HTTP::Middleware.build do use Luna::Middleware::Verbose if verbose use ::Protocol::HTTP::ContentEncoding use Luna::Middleware::Markdown, root: root if markdown run Luna::Middleware::Static.new( ->(request){Protocol::HTTP::Response[404, {"content-type"=>"text/plain"}, ["Not Found"]]}, root: root, index: index, directory_listing: directory_listing ) end end |