telize

High performance JSON IP and GeoIP REST API (IP Geolocation)
Log | Files | Refs | README | LICENSE

commit cff6efc63f269d7cc582367037edc1f2aefc336d
parent 790381eba21f17962f2a44f22038f22396297c1c
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri,  5 Oct 2018 22:32:38 +0200

Add 'region' and 'region_code' fields to the payload

Diffstat:
Msrc/location.c | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/location.c b/src/location.c @@ -100,6 +100,16 @@ location(struct http_request *req) json_object_set_new(output, "country_code", json_string(strndup(entry_data.utf8_string, entry_data.data_size))); } + MMDB_get_value(&lookup.entry, &entry_data, "subdivisions", "0", "names", "en", NULL); + if (entry_data.has_data) { + json_object_set_new(output, "region", json_string(strndup(entry_data.utf8_string, entry_data.data_size))); + } + + MMDB_get_value(&lookup.entry, &entry_data, "subdivisions", "0", "iso_code", NULL); + if (entry_data.has_data) { + json_object_set_new(output, "region_code", json_string(strndup(entry_data.utf8_string, entry_data.data_size))); + } + MMDB_get_value(&lookup.entry, &entry_data, "city", "names", "en", NULL); if (entry_data.has_data) { json_object_set_new(output, "city", json_string(strndup(entry_data.utf8_string, entry_data.data_size)));