Class: Akainaa::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/akainaa.rb

Constant Summary collapse

PADDING =
4
CoverageSummary =
Data.define(:file_path_has_max_count, :max_count_on_proj)

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



124
125
126
# File 'lib/akainaa.rb', line 124

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/akainaa.rb', line 128

def call(env)
  if env['PATH_INFO'] == '/akainaa'
    path = extract_path_from_query(env)
    html = render_page(path)

    [200, { 'Content-Type' => 'text/html;charset=utf-8' }, [html]]
  elsif env['PATH_INFO'] == '/akainaa/reset'
    path = extract_path_from_query(env)
    Akainaa.reset

    [302, { 'Location' => "/akainaa?path=#{path}" }, []]
  else
    @app.call(env)
  end
end