HashBody returns the sha256 hex of the raw request body. Exposed so callers (the HTTP layer) can compute it once from the bytes they already read, rather than re-reading or re-encoding.
(body []byte)
| 104 | // callers (the HTTP layer) can compute it once from the bytes they |
| 105 | // already read, rather than re-reading or re-encoding. |
| 106 | func HashBody(body []byte) string { |
| 107 | sum := sha256.Sum256(body) |
| 108 | return hex.EncodeToString(sum[:]) |
| 109 | } |
| 110 | |
| 111 | // HashRequest mixes the request path into the body hash so the same |
| 112 | // Idempotency-Key cannot accidentally replay a cached response across |
no outgoing calls