Skip to content
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

feat: add request remote address to context #447

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions adapters/humabunrouter/humabunrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (c *bunContext) Host() string {
return c.r.Host
}

func (c *bunContext) RemoteAddr() string {
return c.r.RemoteAddr
}

func (c *bunContext) URL() url.URL {
return *c.r.URL
}
Expand Down Expand Up @@ -131,6 +135,10 @@ func (c *bunCompatContext) Host() string {
return c.r.Host
}

func (c *bunCompatContext) RemoteAddr() string {
return c.r.RemoteAddr
}

func (c *bunCompatContext) URL() url.URL {
return *c.r.URL
}
Expand Down
4 changes: 4 additions & 0 deletions adapters/humachi/humachi.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (c *chiContext) Host() string {
return c.r.Host
}

func (c *chiContext) RemoteAddr() string {
return c.r.RemoteAddr
}

func (c *chiContext) URL() url.URL {
return *c.r.URL
}
Expand Down
4 changes: 4 additions & 0 deletions adapters/humaecho/humaecho.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (c *echoCtx) Host() string {
return c.orig.Request().Host
}

func (c *echoCtx) RemoteAddr() string {
return c.orig.Request().RemoteAddr
}

func (c *echoCtx) URL() url.URL {
return *c.orig.Request().URL
}
Expand Down
4 changes: 4 additions & 0 deletions adapters/humafiber/humafiber.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (c *fiberCtx) Host() string {
return c.orig.Hostname()
}

func (c *fiberCtx) RemoteAddr() string {
return c.orig.Context().RemoteAddr().String()
}

func (c *fiberCtx) URL() url.URL {
u, _ := url.Parse(string(c.orig.Request().RequestURI()))
return *u
Expand Down
4 changes: 4 additions & 0 deletions adapters/humaflow/humaflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func (c *goContext) Host() string {
return c.r.Host
}

func (c *goContext) RemoteAddr() string {
return c.r.RemoteAddr
}

func (c *goContext) URL() url.URL {
return *c.r.URL
}
Expand Down
4 changes: 4 additions & 0 deletions adapters/humagin/humagin.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (c *ginCtx) Host() string {
return c.orig.Request.Host
}

func (c *ginCtx) RemoteAddr() string {
return c.orig.Request.RemoteAddr
}

func (c *ginCtx) URL() url.URL {
return *c.orig.Request.URL
}
Expand Down
4 changes: 4 additions & 0 deletions adapters/humago/humago.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (c *goContext) Host() string {
return c.r.Host
}

func (c *goContext) RemoteAddr() string {
return c.r.RemoteAddr
}

func (c *goContext) URL() url.URL {
return *c.r.URL
}
Expand Down
4 changes: 4 additions & 0 deletions adapters/humahttprouter/humahttprouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (c *httprouterContext) Host() string {
return c.r.Host
}

func (c *httprouterContext) RemoteAddr() string {
return c.r.RemoteAddr
}

func (c *httprouterContext) URL() url.URL {
return *c.r.URL
}
Expand Down
4 changes: 4 additions & 0 deletions adapters/humamux/humamux.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (c *gmuxContext) Host() string {
return c.r.Host
}

func (c *gmuxContext) RemoteAddr() string {
return c.r.RemoteAddr
}

func (c *gmuxContext) URL() url.URL {
return *c.r.URL
}
Expand Down
3 changes: 3 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type Context interface {
// Host returns the HTTP host for the request.
Host() string

// RemoteAddr returns the remote address of the client.
RemoteAddr() string

// URL returns the full URL for the request.
URL() url.URL

Expand Down
Loading