5d0221f67d464d1c2644f325a0a8936afd75ad97
GeoIP REST (Go Fiber)
간단한 GeoIP 조회 API입니다. GeoLite2-City.mmdb를 사용해
IP를 나라/지역/도시/위도/경도로 매핑합니다.
요구 사항
- Go 1.25+
GeoLite2-City.mmdb(레포지토리 루트에 위치)- Docker / Docker Compose (컨테이너 실행 시)
설치 및 실행
로컬 (Go)
Docker Compose
GeoLite2-City.mmdb가 컨테이너에 read-only로 마운트됩니다.- 기본 포트:
8080.
환경 변수
PORT(기본8080): 서버 리스닝 포트GEOIP_DB_PATH(기본/data/GeoLite2-City.mmdb): GeoIP 데이터베이스 경로
사용법
- 헬스체크:
GET /health - 조회:
GET /lookup?ip=<IPv4|IPv6>ip생략 시 호출자 IP를 사용
예시:
응답 예시:
{
"IP": "1.1.1.1",
"Country": "Australia",
"Region": "Queensland",
"City": "South Brisbane",
"Address": "South Brisbane, Queensland, Australia",
"Latitude": -27.4748,
"Longitude": 153.017
}개발 참고
- 주요 코드:
cmd/server/main.go,internal/geo/resolver.go - 테스트 실행:
go test ./... - 컨테이너 빌드:
docker build -t geoip:local .
Description
Languages
Go
95.1%
PLpgSQL
2.7%
Dockerfile
2.2%