mirror of
https://github.com/TheWhiteDog9487/WebAPI.git
synced 2026-08-11 23:01:30 +08:00
增加对获取自身ip对应的iso3166代码的支持
提升版本号,之前一直都没改过,之后应该都会改了
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.thewhitedog9487"
|
group = "xyz.thewhitedog9487"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
|
|||||||
@@ -35,7 +35,18 @@ class IP {
|
|||||||
HttpStatus.OK); }
|
HttpStatus.OK); }
|
||||||
else {
|
else {
|
||||||
return new ResponseEntity<>(Request.getRemoteAddr(),
|
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")),
|
MultiValueMap.fromSingleValue(Map.of("Content-Type", "text/plain;charset=UTF-8")),
|
||||||
HttpStatus.OK); }
|
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); } }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user