Port returns the remote port of the request.
()
| 532 | |
| 533 | // Port returns the remote port of the request. |
| 534 | func (r *DefaultReq) Port() string { |
| 535 | addr := r.c.fasthttp.RemoteAddr() |
| 536 | if addr == nil { |
| 537 | return "0" |
| 538 | } |
| 539 | switch typedAddr := addr.(type) { |
| 540 | case *net.TCPAddr: |
| 541 | return strconv.Itoa(typedAddr.Port) |
| 542 | case *net.UnixAddr: |
| 543 | return "" |
| 544 | } |
| 545 | |
| 546 | _, port, err := net.SplitHostPort(addr.String()) |
| 547 | if err != nil { |
| 548 | return "" |
| 549 | } |
| 550 | |
| 551 | return port |
| 552 | } |
| 553 | |
| 554 | // IP returns the client's IP address. When the request comes from a trusted proxy (see |
| 555 | // [TrustProxyConfig]), the value is extracted from the configured ProxyHeader by walking the |
nothing calls this directly
no test coverage detected