mirror of
https://github.com/TheWhiteDog9487/WebAPI.git
synced 2026-08-11 23:01:30 +08:00
增加对获取自身ip对应的iso3166代码的支持
提升版本号,之前一直都没改过,之后应该都会改了
This commit is contained in:
@@ -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); } }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user