MCPcopy
hub / github.com/gofiber/fiber / Port

Method Port

req.go:534–552  ·  view source on GitHub ↗

Port returns the remote port of the request.

()

Source from the content-addressed store, hash-verified

532
533// Port returns the remote port of the request.
534func (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

Callers

nothing calls this directly

Calls 2

RemoteAddrMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected