-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AYS-379 | Rate Limit Feature Has Been Integrated (#380)
- Loading branch information
1 parent
e77a099
commit 40d9f6d
Showing
5 changed files
with
148 additions
and
14 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/org/ays/common/util/HttpServletRequestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.ays.common.util; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public class HttpServletRequestUtil { | ||
|
||
public static String getClientIpAddress(final HttpServletRequest httpServletRequest) { | ||
|
||
final String ipAddress = httpServletRequest.getHeader("X-Forwarded-For"); | ||
if (ipAddress == null || ipAddress.isEmpty()) { | ||
return httpServletRequest.getRemoteAddr().trim(); | ||
} | ||
|
||
return ipAddress.split(",")[0].trim(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters