Skip to content

Commit

Permalink
fix(): typo
Browse files Browse the repository at this point in the history
  • Loading branch information
n33pm committed Apr 9, 2024
1 parent 3433509 commit cb43924
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions middleware/realip.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ func RealIP(h http.Handler) http.Handler {
return http.HandlerFunc(fn)
}

// RealIPCustomHeader is a middleware that sets a http.Request's RemoteAddr to the results
// RealIPFromHeaders is a middleware that sets a http.Request's RemoteAddr to the results
// of parsing the custom headers.
//
// usage:
// r.Use(RealIPCustomHeader([]string{"X-CUSTOM-IP"}))
// r.Use(RealIPCustomHeader(append(DefaultRealIPHeaders, "X-CUSTOM-IP")))
func RealIPCustomHeader(realIPHeaders []string) func(http.Handler) http.Handler {
// r.Use(RealIPFromHeaders([]string{"CF-Connecting-IP"}))
// r.Use(RealIPFromHeaders(append(DefaultRealIPHeaders, "CF-Connecting-IP")))
func RealIPFromHeaders(realIPHeaders []string) func(http.Handler) http.Handler {
f := func(h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
if rip := getRealIP(r, realIPHeaders); rip != "" {
Expand Down
4 changes: 2 additions & 2 deletions middleware/realip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestCustomIPHeader(t *testing.T) {
w := httptest.NewRecorder()

r := chi.NewRouter()
r.Use(RealIPCustomHeader([]string{customHeaderKey}))
r.Use(RealIPFromHeaders([]string{customHeaderKey}))

realIP := ""
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -145,7 +145,7 @@ func TestCustomIPHeaderWithoutDefault(t *testing.T) {
w := httptest.NewRecorder()

r := chi.NewRouter()
r.Use(RealIPCustomHeader([]string{"X-CUSTOM-IP"}))
r.Use(RealIPFromHeaders([]string{"X-CUSTOM-IP"}))

realIP := ""
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit cb43924

Please sign in to comment.