String returns unique string representation of the ctx. The returned value may be useful for logging.
()
| 587 | // |
| 588 | // The returned value may be useful for logging. |
| 589 | func (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 |
nothing calls this directly
no test coverage detected