diff options
| author | mo khan <mo@mokhan.ca> | 2015-10-18 16:33:05 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-10-18 16:33:05 -0600 |
| commit | 04cf2dcd6ce172c36a87da49a24390293072b666 (patch) | |
| tree | ba1db28098c2b89b4cab37b23f293942fa0cab49 | |
| parent | 354a97f614ce32788c049df3556baac5e708b48f (diff) | |
add ip address filter.
| -rw-r--r-- | lib/killjoy/web.rb | 10 | ||||
| -rw-r--r-- | lib/killjoy/web/views/index.erb | 14 |
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/killjoy/web.rb b/lib/killjoy/web.rb index 8951781..4d516bd 100644 --- a/lib/killjoy/web.rb +++ b/lib/killjoy/web.rb @@ -18,7 +18,15 @@ get '/' do erb :index end +get '/ip/:ipaddress' do + @logs = Killjoy::CassandraDb + .from(:log_lines) + .where(ipaddress: IPAddr.new(params['ipaddress'])) + .limit(100) + .map { |x| Killjoy::LogLine.new(x) } + erb :index +end + get '/ping' do "Hello World!" end - diff --git a/lib/killjoy/web/views/index.erb b/lib/killjoy/web/views/index.erb index 4f2a926..3561cf6 100644 --- a/lib/killjoy/web/views/index.erb +++ b/lib/killjoy/web/views/index.erb @@ -1,25 +1,25 @@ -<h1>Logs</h1> +<h1><a href="/">Logs</a></h1> <table> <thead> <tr> <th>IP Address</th> - <th>Http Status</th> - <th>Http Verb</th> - <th>Http Version</th> - <th>Timestamp</th> + <th>Status</th> + <th>Verb</th> <th>Url</th> + <th>Version</th> + <th>Timestamp</th> <th>User Agent</th> </tr> </thead> <tbody> <% @logs.each do |log| %> <tr> - <td><%= log.ipaddress %></td> + <td><a href="/ip/<%= log.ipaddress %>"><%= log.ipaddress %></a></td> <td><%= log.http_status %></td> <td><%= log.http_verb %></td> + <td><%= log.url %></td> <td><%= log.http_version %></td> <td><%= log.timestamp %></td> - <td><%= log.url %></td> <td><%= log.user_agent %></td> </tr> <% end %> |
