增加对获取自身ip对应的iso3166代码的支持

提升版本号,之前一直都没改过,之后应该都会改了
This commit is contained in:
2025-08-15 15:46:39 +08:00
parent 7cc39aa3d7
commit 8681359d34
2 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ plugins {
}
group = "xyz.thewhitedog9487"
version = "0.1.0"
version = "0.2.0"
java {
toolchain {
@@ -35,7 +35,18 @@ class IP {
HttpStatus.OK); }
else {
return new ResponseEntity<>(Request.getRemoteAddr(),
MultiValueMap.fromSingleValue(Map.of("Content-Type", "text/plain;charset=UTF-8")),
HttpStatus.OK); } }
@GetMapping("iso3166")
ResponseEntity<String> GetISO3166(@RequestHeader Map<String, String> HttpHeader) {
if (HttpHeader.get("CF-IPCountry".toLowerCase()) instanceof String CountryCode) {
return new ResponseEntity<>(CountryCode,
MultiValueMap.fromSingleValue(Map.of("Content-Type", "text/plain;charset=UTF-8")),
HttpStatus.OK); }
}
else {
log.warn("请求尝试获取其ip对应的iso3166代码,但是我们没有找到CF-IPCountry头部");
return new ResponseEntity<>("未找到CF-IPCountry头部",
MultiValueMap.fromSingleValue(Map.of("Content-Type", "text/plain;charset=UTF-8")),
HttpStatus.NOT_FOUND); } }
}