Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 17ce9a4887 | |||
| 28c2503852 | |||
| f09bf691d1 | |||
| d01edf9718 | |||
| fbcab6a37d | |||
| 1fe505d0ae |
+3
-3
@@ -2,13 +2,13 @@ version: 2.0
|
||||
shards:
|
||||
db:
|
||||
git: https://github.com/crystal-lang/crystal-db.git
|
||||
version: 0.9.0
|
||||
version: 0.11.0
|
||||
|
||||
pg:
|
||||
git: https://github.com/will/crystal-pg.git
|
||||
version: 0.21.1
|
||||
version: 0.26.0
|
||||
|
||||
sqlite3:
|
||||
git: https://github.com/crystal-lang/crystal-sqlite3.git
|
||||
version: 0.16.0
|
||||
version: 0.19.0
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: access_log
|
||||
version: 0.2.0
|
||||
version: 0.3.0
|
||||
|
||||
authors:
|
||||
- f <f@sutty.nl>
|
||||
|
||||
+3
-2
@@ -6,7 +6,7 @@ require "uuid"
|
||||
require "./models/access_log"
|
||||
require "./models/crawler"
|
||||
|
||||
VERSION = "0.2.0"
|
||||
VERSION = "0.3.0"
|
||||
|
||||
# The default database URI
|
||||
database = "sqlite3://./development.sqlite3"
|
||||
@@ -16,7 +16,7 @@ crawler = false
|
||||
crawlers = [] of Crawler
|
||||
# Fields in database
|
||||
# TODO: Obtain them from AccessLog
|
||||
fields = ["id", "remote_user", "host", "msec", "server_protocol", "request_method", "request_completion", "uri", "query_string", "status", "sent_http_content_type", "sent_http_content_encoding", "sent_http_etag", "sent_http_last_modified", "http_accept", "http_accept_encoding", "http_accept_language", "http_pragma", "http_cache_control", "http_if_none_match", "http_dnt", "http_user_agent", "http_origin", "http_referer", "request_time", "bytes_sent", "body_bytes_sent", "request_length", "http_connection", "pipe", "connection_requests", "geoip2_data_country_name", "geoip2_data_city_name", "ssl_server_name", "ssl_protocol", "ssl_early_data", "ssl_session_reused", "ssl_curves", "ssl_ciphers", "ssl_cipher", "sent_http_x_xss_protection", "sent_http_x_frame_options", "sent_http_x_content_type_options", "sent_http_strict_transport_security", "nginx_version", "pid", "crawler"]
|
||||
fields = ["id", "remote_user", "host", "msec", "server_protocol", "request_method", "request_completion", "uri", "request_uri", "query_string", "status", "sent_http_content_type", "sent_http_content_encoding", "sent_http_etag", "sent_http_last_modified", "http_accept", "http_accept_encoding", "http_accept_language", "http_pragma", "http_cache_control", "http_if_none_match", "http_dnt", "http_user_agent", "http_origin", "http_referer", "request_time", "bytes_sent", "body_bytes_sent", "request_length", "http_connection", "pipe", "connection_requests", "geoip2_data_country_name", "geoip2_data_city_name", "ssl_server_name", "ssl_protocol", "ssl_early_data", "ssl_session_reused", "ssl_curves", "ssl_ciphers", "ssl_cipher", "sent_http_x_xss_protection", "sent_http_x_frame_options", "sent_http_x_content_type_options", "sent_http_strict_transport_security", "nginx_version", "pid", "crawler"]
|
||||
# Params for the query
|
||||
params = [] of String
|
||||
|
||||
@@ -94,6 +94,7 @@ db = DB.open database do |db|
|
||||
access_log.request_method,
|
||||
access_log.request_completion,
|
||||
access_log.uri,
|
||||
access_log.request_uri,
|
||||
access_log.query_string,
|
||||
access_log.status,
|
||||
access_log.sent_http_content_type,
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# Removes query string from request URI as we are already storing it in
|
||||
# query_string.
|
||||
module JSON::RequestUriConverter(Converter)
|
||||
def self.from_json(value : JSON::PullParser)
|
||||
value.read_string.split("?", 2).first
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
require "json"
|
||||
require "../json/referrer_policy_converter"
|
||||
require "../json/request_uri_converter"
|
||||
|
||||
class AccessLog
|
||||
include JSON::Serializable
|
||||
@@ -11,6 +12,10 @@ class AccessLog
|
||||
property request_method : String
|
||||
property request_completion : String
|
||||
property uri : String
|
||||
|
||||
@[JSON::Field(converter: JSON::RequestUriConverter(String::Converter))]
|
||||
property request_uri : String
|
||||
|
||||
property query_string : String
|
||||
property status : Int32
|
||||
property sent_http_content_type : String
|
||||
@@ -53,4 +58,3 @@ class AccessLog
|
||||
property nginx_version : String
|
||||
property pid : String
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user