Class: Jekyll::Commands::Serve::Servlet
- Inherits:
-
WEBrick::HTTPServlet::FileHandler
- Object
- WEBrick::HTTPServlet::FileHandler
- Jekyll::Commands::Serve::Servlet
- Defined in:
- lib/jekyll/commands/serve/servlet.rb
Constant Summary collapse
- DEFAULTS =
{ "Cache-Control" => "private, max-age=0, proxy-revalidate, " \ "no-store, no-cache, must-revalidate" }
Instance Method Summary collapse
- #basic_auth(request, response) ⇒ Object
- #do_GET(req, res) ⇒ Object
-
#initialize(server, root, callbacks) ⇒ Servlet
constructor
A new instance of Servlet.
-
#search_file(req, res, basename) ⇒ Object
Add the ability to tap file.html the same way that Nginx does on our Docker images (or on GitHub Pages.) The difference is that we might end up with a different preference on which comes first.
Constructor Details
Instance Method Details
#basic_auth(request, response) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 12 def basic_auth(request, response) WEBrick::HTTPAuth.basic_auth(request, response, 'My Realm') do |user, pass| credentials = SafeYAML.load_file(Jekyll::Configuration::DEFAULTS['source'] + '/admin/config.yml') user == credentials['user'] && pass == credentials['password'] end end |
#do_GET(req, res) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 37 def do_GET(req, res) basic_auth(req, res) rtn = super validate_and_ensure_charset(req, res) res.header.merge!(@headers) rtn end |
#search_file(req, res, basename) ⇒ Object
Add the ability to tap file.html the same way that Nginx does on our Docker images (or on GitHub Pages.) The difference is that we might end up with a different preference on which comes first.
30 31 32 33 |
# File 'lib/jekyll/commands/serve/servlet.rb', line 30 def search_file(req, res, basename) # /file.* > /file/index.html > /file.html super || super(req, res, "#{basename}.html") end |