-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api: Support to get http client ip #4495
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
/run-all-tests |
server/server_test.go
Outdated
bodyBytes, err := io.ReadAll(resp.Body) | ||
c.Assert(err, IsNil) | ||
bodyString := string(bodyBytes) | ||
c.Assert(bodyString, Equals, "Hello World\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why delete these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems it should be reserved. Because it should not break the original test
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #4495 +/- ##
==========================================
- Coverage 74.95% 74.92% -0.03%
==========================================
Files 265 265
Lines 27851 27861 +10
==========================================
Hits 20875 20875
- Misses 5122 5129 +7
- Partials 1854 1857 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -204,6 +205,9 @@ func (s *testServerHandlerSuite) TestRegisterServerHandler(c *C) { | |||
mux := http.NewServeMux() | |||
mux.HandleFunc("/pd/apis/mok/v1/hello", func(w http.ResponseWriter, r *http.Request) { | |||
fmt.Fprintln(w, "Hello World") | |||
// test getting ip | |||
clientIP := apiutil.GetIPAddrFromHTTPRequest(r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to cover all cases in our test.
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
/merge |
@nolouch: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: 7efb6ff
|
/run-all-tests |
1 similar comment
/run-all-tests |
Signed-off-by: Cabinfever_B cabinfeveroier@gmail.com
What problem does this PR solve?
close #4494
What is changed and how it works?
According to related blogs, it gets client IP from header
X-Forwarded-For
to headerX-Real-Ip
torequest.RemoteAddr
Check List
Tests
Release note