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

Method String

ctx.go:589–624  ·  view source on GitHub ↗

String returns unique string representation of the ctx. The returned value may be useful for logging.

()

Source from the content-addressed store, hash-verified

587//
588// The returned value may be useful for logging.
589func (c *DefaultCtx) String() string {
590 // Get buffer from pool
591 buf := bytebufferpool.Get()
592
593 // Start with the ID, converting it to a hex string without fmt.Sprintf
594 buf.WriteByte('#')
595 const hex = "0123456789abcdef"
596 var id [16]byte
597 ctxID := c.fasthttp.ID()
598 for i := len(id) - 1; i >= 0; i-- {
599 id[i] = hex[ctxID&0xf]
600 ctxID >>= 4
601 }
602 buf.Write(id[:])
603 buf.WriteString(" - ")
604
605 // Add local and remote addresses directly
606 buf.WriteString(c.fasthttp.LocalAddr().String())
607 buf.WriteString(" <-> ")
608 buf.WriteString(c.fasthttp.RemoteAddr().String())
609 buf.WriteString(" - ")
610
611 // Add method and URI
612 buf.Write(c.fasthttp.Request.Header.Method())
613 buf.WriteByte(' ')
614 buf.Write(c.fasthttp.URI().FullURI())
615
616 // Allocate string
617 str := buf.String()
618
619 // Reset buffer
620 buf.Reset()
621 bytebufferpool.Put(buf)
622
623 return str
624}
625
626// Value makes it possible to retrieve values (Locals) under keys scoped to the request
627// and therefore available to all following routes that match the request. If the context

Callers

nothing calls this directly

Calls 12

LocalAddrMethod · 0.80
RemoteAddrMethod · 0.80
URIMethod · 0.80
GetMethod · 0.65
WriteByteMethod · 0.65
WriteMethod · 0.65
WriteStringMethod · 0.65
StringMethod · 0.65
MethodMethod · 0.65
ResetMethod · 0.65
PutMethod · 0.65
IDMethod · 0.45

Tested by

no test coverage detected