Add headers with GeoIP data
This commit is contained in:
parent
da3ed5ebbf
commit
d22396c298
@ -130,6 +130,7 @@ sub register {
|
||||
$self->{_args}{db_dir} ||= '/usr/local/share/GeoIP';
|
||||
|
||||
$self->load_geoip() or return;
|
||||
$self->register_hook( data_post => 'add_headers' );
|
||||
}
|
||||
|
||||
sub load_geoip {
|
||||
@ -197,6 +198,17 @@ sub load_geoip2 {
|
||||
return;
|
||||
}
|
||||
|
||||
sub add_headers {
|
||||
my ( $self, $txn ) = @_;
|
||||
for my $h (qw( Country Country-Name Continent City ASN )) {
|
||||
my $note = lc "geoip_$h";
|
||||
$h =~ s/-/_/;
|
||||
next if ! $self->connection->notes($note);
|
||||
$txn->header->delete("X-GeoIP-$h");
|
||||
$txn->header->add( "X-GeoIP-$h", $self->connection->notes($note), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
sub geoip2_lookup {
|
||||
my $self = shift;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user