P0 fixes: - ModelError.Is(): use exact matching instead of substring contains() - shouldClearStickySession: add context param for cancellation/tracing P1 fixes: - TODO stubs: return 501 Not Implemented errors - validateInstanceSignature: deduplicate to shared validateCodeSignature() - Error messages: standardize to English only - http.go: remove pseudo if-else with duplicate branches
29 lines
743 B
Go
29 lines
743 B
Go
package service
|
|
|
|
import "strings"
|
|
|
|
func optionalTrimmedStringPtr(raw string) *string {
|
|
trimmed := strings.TrimSpace(raw)
|
|
if trimmed == "" {
|
|
return nil
|
|
}
|
|
return &trimmed
|
|
}
|
|
|
|
// optionalNonEqualStringPtr returns a pointer to value if it is non-empty and
|
|
// differs from compare; otherwise nil. Used to store upstream_model only when
|
|
// it differs from the requested model.
|
|
func optionalNonEqualStringPtr(value, compare string) *string {
|
|
if value == "" || value == compare {
|
|
return nil
|
|
}
|
|
return &value
|
|
}
|
|
|
|
func forwardResultBillingModel(requestedModel, upstreamModel string) string {
|
|
if trimmedUpstream := strings.TrimSpace(upstreamModel); trimmedUpstream != "" {
|
|
return trimmedUpstream
|
|
}
|
|
return strings.TrimSpace(requestedModel)
|
|
}
|