{"id":23128013,"url":"https://github.com/antoniojmsjr/horse-ipgeolocation","last_synced_at":"2025-07-24T00:37:33.547Z","repository":{"id":113070994,"uuid":"461381651","full_name":"antoniojmsjr/Horse-IPGeoLocation","owner":"antoniojmsjr","description":"⚡ Middleware de geolocalização baseada em endereço IP, desenvolvido parar o framework Horse.","archived":false,"fork":false,"pushed_at":"2022-04-11T22:11:10.000Z","size":169,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T05:43:35.288Z","etag":null,"topics":["delphi","horse","ipgeolocation"],"latest_commit_sha":null,"homepage":"","language":"Pascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antoniojmsjr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-20T04:18:14.000Z","updated_at":"2024-07-16T17:01:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"5dc2f359-8938-47a4-8469-cd9aadd2ab3f","html_url":"https://github.com/antoniojmsjr/Horse-IPGeoLocation","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/antoniojmsjr/Horse-IPGeoLocation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojmsjr%2FHorse-IPGeoLocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojmsjr%2FHorse-IPGeoLocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojmsjr%2FHorse-IPGeoLocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojmsjr%2FHorse-IPGeoLocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antoniojmsjr","download_url":"https://codeload.github.com/antoniojmsjr/Horse-IPGeoLocation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antoniojmsjr%2FHorse-IPGeoLocation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266774797,"owners_count":23982247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["delphi","horse","ipgeolocation"],"created_at":"2024-12-17T09:16:08.327Z","updated_at":"2025-07-24T00:37:33.533Z","avatar_url":"https://github.com/antoniojmsjr.png","language":"Pascal","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Maintained YES](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=flat-square\u0026color=important)\n![Memory Leak Verified YES](https://img.shields.io/badge/Memory%20Leak%20Verified%3F-yes-green.svg?style=flat-square\u0026color=important)\n![Delphi Supported Versions](https://img.shields.io/badge/Delphi%20Supported%20Versions-Tokyo%2010.2.3%20and%20above-blue.svg?style=flat-square)\n![HorseVersion](https://img.shields.io/badge/Horse%20minimum%20version-v3.0.1-blue.svg?style=flat-square)\n![Stars](https://img.shields.io/github/stars/antoniojmsjr/Horse-IPGeoLocation.svg?style=flat-square)\n![Forks](https://img.shields.io/github/forks/antoniojmsjr/Horse-IPGeoLocation.svg?style=flat-square)\n![Issues](https://img.shields.io/github/issues/antoniojmsjr/Horse-IPGeoLocation.svg?style=flat-square\u0026color=blue)\n![Release](https://img.shields.io/github/v/release/antoniojmsjr/Horse-IPGeoLocation?label=Latest%20release\u0026style=flat-square\u0026color=important)\n\n# Horse-IPGeoLocation\n\n**Horse-IPGeoLocation** é um middleware de geolocalização baseada em endereço IP, desenvolvido parar o framework [Horse](https://github.com/HashLoad/horse).\n\n## ❓ O que é a geolocalização de IP?\n\nA geolocalização baseada em endereços IP é uma técnica usada para estimar a localização geográfica de um dispositivo conectado à Internet usando o endereço IP do mesmo. Este mecanismo depende de que o endereço IP do dispositivo apareça em um banco de dados com sua respectiva localização, endereço postal, cidade, país, região ou coordenadas geográficas, que são alguns dos níveis de detalhe que podem ser registrados.\n\n## ⭕ Pré-requisito\n\nPara utilizar o **Horse-IPGeoLocation** é necessário a instalação do framework [IPGeoLocation](https://github.com/antoniojmsjr/IPGeoLocation/releases/latest).\n\n*Obs: Se você usa [**Boss**](https://github.com/HashLoad/boss/releases/latest) (Dependency manager for Delphi), o [IPGeoLocation](https://github.com/antoniojmsjr/IPGeoLocation/releases/latest) será instalado automaticamente ao instalar **Horse-IPGeoLocation**.*\n\n\n## ⚙️ Instalação Automatizada\n\nUtilizando o [**Boss**](https://github.com/HashLoad/boss/releases/latest) (Dependency manager for Delphi) é possível instalar a biblioteca de forma automática.\n\n```\nboss install github.com/antoniojmsjr/Horse-IPGeoLocation\n```\n\n## ⚙️ Instalação Manual\n\nSe você optar por instalar manualmente, basta adicionar as seguintes pastas ao seu projeto, em *Project \u003e Options \u003e Delphi Compiler \u003e Target \u003e All Configurations \u003e Search path*\n\n*Obs: Se você usar a instalação manual, será necessário a instalação do framework [IPGeoLocation](https://github.com/antoniojmsjr/IPGeoLocation/releases/latest).*\n\n```\n..\\Horse-IPGeoLocation\\Source\n```\n\n## 🧬 Provedores IPGeolocation\n\nLista dos principais provedores de IPGeolocation homologados para utilização: [Visualização](https://github.com/antoniojmsjr/IPGeoLocation#provedores-homologados)\n\n## ⚡️ Uso\n\n#### Uso e definição do middleware\n\n```delphi\nuses Horse, Horse.IPGeoLocation, Horse.IPGeoLocation.Types;\n\n//PARA TESTAR IPGeolocation LOCALMENTE\nif (DebugHook \u003c\u003e 0) then\n  THorse.Use(IPGeoLocation(TIPGeoLocationProvider.IPInfo, EmptyStr, '8.8.8.8'))\nelse\n  THorse.Use(IPGeoLocation(TIPGeoLocationProvider.IPInfo, EmptyStr));\n```\n\n```delphi\nfunction IPGeoLocation(const pProvider: TIPGeoLocationProvider;\n                       const pToken: string;\n                       const pAPIKey: Integer;\n                       const pLanguageCode: string): THorseCallback;\n```\n* `pProvider`: Identificação do provedor de IPGeolocation homologado.\n* `pAPIKey`: ApiKey gerado no site do provedor de IPGeolocation identificado no `pProvider`. [opcional]\n* `pTimeOut`: Tempo em milissegundos para finalização da requisição. [opcional]\n* `pLanguageCode`: Identificação do código de idioma utilizado no retorno do JSON. Ex.: pt-br/en-us. [opcional]\n* `pIPDebug`: IP para testar com requisição local.\n  * Requisições locais ou IP privados ao servidor Horse, não será executado o middleware Horse-IPGeoLocation, com a exceção da utilização do `pIPDebug`.\n\n#### Exemplo de visualização do JSON de retorno da requisição do IPGeolocation.\n\n```delphi\nuses Horse, Horse.IPGeoLocation, Horse.IPGeoLocation.Types;\n\nTHorse.Get('ipgeo/json',\n  procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)\n  var\n    lHorseGeoLocation: THorseGeoLocation;\n  begin\n    if Req.Sessions.TryGetSession(lHorseGeoLocation) then\n      Res.Send(lHorseGeoLocation.ToJSON)\n    else\n      Res.Send(Req.RawWebRequest.RemoteAddr);\n  end);\n```\n![image](https://user-images.githubusercontent.com/20980984/161868147-39e9fa2b-0b83-45ac-bbba-4cf0543d0b35.png)\n\n#### Exemplo de visualização do mapa(Google) gerado com o retorno da requisição do IPGeolocation.\n\n```delphi\nuses Horse, Horse.IPGeoLocation, Horse.IPGeoLocation.Types;\n\nTHorse.Get('ipgeo/gmaps',\n  procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)\n  const\n    cURLMaps = 'https://maps.google.com/maps?q=%g,%g'; //1º: LATITUDE/2º: LONGITUDE\n  var\n    lHorseGeoLocation: THorseGeoLocation;\n    lFormatSettings: TFormatSettings;\n    lURLMaps: string;\n  begin\n    lFormatSettings:= TFormatSettings.Create('en-US');\n\n    if Req.Sessions.TryGetSession(lHorseGeoLocation) then\n    begin\n      lURLMaps := Format(cURLMaps, [lHorseGeoLocation.Latitude, lHorseGeoLocation.Longitude], lFormatSettings);\n      Res.RedirectTo(lURLMaps);\n    end\n    else\n      Res.Send(Req.RawWebRequest.RemoteAddr);\n  end);\n```\n\n#### Exemplo de visualização do mapa(Waze) gerado com o retorno da requisição do IPGeolocation.\n\n```delphi\nuses Horse, Horse.IPGeoLocation, Horse.IPGeoLocation.Types;\n\nTHorse.Get('ipgeo/wmaps',\n  procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)\n  const\n    cURLMaps = 'https://waze.com/ul?ll=%g,%g\u0026z=10'; //1º: LATITUDE/2º: LONGITUDE\n  var\n    lHorseGeoLocation: THorseGeoLocation;\n    lFormatSettings: TFormatSettings;\n    lURLMaps: string;\n  begin\n    lFormatSettings:= TFormatSettings.Create('en-US');\n\n    if Req.Sessions.TryGetSession(lHorseGeoLocation) then\n    begin\n      lURLMaps := Format(cURLMaps, [lHorseGeoLocation.Latitude, lHorseGeoLocation.Longitude], lFormatSettings);\n      Res.RedirectTo(lURLMaps);\n    end\n    else\n      Res.Send(Req.RawWebRequest.RemoteAddr);\n  end);\n```\n## ⚠️ Licença\n`Horse-IPGeoLocation` is free and open-source software licensed under the [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://github.com/antoniojmsjr/Horse-IPGeoLocation/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniojmsjr%2Fhorse-ipgeolocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantoniojmsjr%2Fhorse-ipgeolocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantoniojmsjr%2Fhorse-ipgeolocation/lists"}