MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / newRequestID

Function newRequestID

internal/httpapi/middleware.go:27–33  ·  view source on GitHub ↗

newRequestID returns a short, URL-safe, prefixed request id. crypto/rand is used so ids aren't guessable; on the astronomically unlikely read failure we fall back to a fixed sentinel rather than panicking a request.

()

Source from the content-addressed store, hash-verified

25// is used so ids aren't guessable; on the astronomically unlikely read
26// failure we fall back to a fixed sentinel rather than panicking a request.
27func newRequestID() string {
28 b := make([]byte, 12)
29 if _, err := rand.Read(b); err != nil {
30 return "req_unknown"
31 }
32 return "req_" + hex.EncodeToString(b)
33}
34
35// RequestIDFromContext returns the request id stamped by the requestID
36// middleware, or "" if none is present.

Callers 1

requestIDFunction · 0.85

Calls 1

makeFunction · 0.85

Tested by

no test coverage detected