class Lanyon::Application

Rack application that serves the Jekyll site.

Not to be instantiated directly, use Lanyon.application instead.

Attributes

router[R]

Public Class Methods

new(router) click to toggle source
# File lib/lanyon/application.rb, line 18
def initialize(router)
  @router = router
end

Public Instance Methods

call(env) click to toggle source
# File lib/lanyon/application.rb, line 22
def call(env)
  request = Rack::Request.new(env)
  endpoint = router.endpoint(request.path_info)

  case endpoint
  when :not_found
    not_found_response
  when :must_redirect
    redirect_to_dir_response(request.path_info)
  else
    case request.request_method
    when "HEAD", "GET"
      response(endpoint)
    when "OPTIONS"
      [200, { "Allow" => "GET,HEAD,OPTIONS", "Content-Length" => "0" }, []]
    else
      not_allowed_response
    end
  end
end