26 lines
959 B
Go
26 lines
959 B
Go
|
|
package decision
|
||
|
|
|
||
|
|
import "context"
|
||
|
|
|
||
|
|
// LosslessJSONProfile is an explicit optional wire decoder profile for the
|
||
|
|
// normal /v1/check handler. Legacy callers retain their original float64
|
||
|
|
// projection. The canonical request and signature algorithms are unchanged.
|
||
|
|
const LosslessJSONProfile = "lossless-json-v1"
|
||
|
|
const losslessStandaloneMode = "standalone/lossless-json-v1"
|
||
|
|
|
||
|
|
type jsonProfileContextKey struct{}
|
||
|
|
|
||
|
|
// WithLosslessJSONProfile is called only by the producer after selecting its
|
||
|
|
// UseNumber decoder. No request/body flag can install this context key. The
|
||
|
|
// signed provenance mode authenticates which decoder produced the decision.
|
||
|
|
func WithLosslessJSONProfile(ctx context.Context) context.Context {
|
||
|
|
return context.WithValue(ctx, jsonProfileContextKey{}, LosslessJSONProfile)
|
||
|
|
}
|
||
|
|
|
||
|
|
func envelopeMode(ctx context.Context) string {
|
||
|
|
if ctx.Value(jsonProfileContextKey{}) == LosslessJSONProfile {
|
||
|
|
return losslessStandaloneMode
|
||
|
|
}
|
||
|
|
return "standalone"
|
||
|
|
}
|