6 Commits

Author SHA1 Message Date
fauno 17ce9a4887 Merge branch 'master' of 0xacab.org:sutty/access_log 2022-03-04 00:15:03 -03:00
fauno 28c2503852 v0.3.0 -- parse request_uri 2022-03-04 00:14:14 -03:00
fauno f09bf691d1 upgrade dependencies 2022-03-04 00:14:00 -03:00
fauno d01edf9718 parse request_uri and remove query_string
sutty/containers/nginx!1
2022-03-04 00:10:50 -03:00
Nulo fbcab6a37d Merge branch 'request-uri' into 'master'
parse request_uri and remove query_string

See merge request sutty/access_log!1
2021-07-22 23:00:23 +00:00
fauno 1fe505d0ae parse request_uri and remove query_string 2021-07-22 23:00:22 +00:00
5 changed files with 19 additions and 7 deletions
+3 -3
View File
@@ -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 -1
View File
@@ -1,5 +1,5 @@
name: access_log
version: 0.2.0
version: 0.3.0
authors:
- f <f@sutty.nl>
+3 -2
View File
@@ -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,
+7
View File
@@ -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
+5 -1
View File
@@ -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