Skip to content

Commit

Permalink
[GIB-119] Add more atomic types to conversion (#150)
Browse files Browse the repository at this point in the history
* [GIB-119] Add more atomic types to conversion

* Addressing Gal's comment

---------

Co-authored-by: Alex Toker <[email protected]>
  • Loading branch information
alxtkr77 and Alex Toker authored Jun 13, 2024
1 parent 6a96832 commit 919d54d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/dataplane/http/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -1221,10 +1221,26 @@ func (c *context) encodeTypedAttributes(attributes map[string]interface{}) (map[
return nil, fmt.Errorf("unexpected attribute type for %s: %T", attributeName, value)
case int:
typedAttributes[attributeName]["N"] = strconv.Itoa(value)
case uint:
typedAttributes[attributeName]["N"] = strconv.FormatUint(uint64(value), 10)
case int8:
typedAttributes[attributeName]["N"] = strconv.Itoa(int(value))
case uint8:
typedAttributes[attributeName]["N"] = strconv.Itoa(int(value))
case int16:
typedAttributes[attributeName]["N"] = strconv.Itoa(int(value))
case uint16:
typedAttributes[attributeName]["N"] = strconv.Itoa(int(value))
case int32:
typedAttributes[attributeName]["N"] = strconv.FormatInt(int64(value), 10)
case uint32:
typedAttributes[attributeName]["N"] = strconv.FormatUint(uint64(value), 10)
case uint64:
typedAttributes[attributeName]["N"] = strconv.FormatUint(value, 10)
case int64:
typedAttributes[attributeName]["N"] = strconv.FormatInt(value, 10)
case float32:
typedAttributes[attributeName]["N"] = strconv.FormatFloat(float64(value), 'E', -1, 32)
// this is a tmp bypass to the fact Go maps Json numbers to float64
case float64:
typedAttributes[attributeName]["N"] = strconv.FormatFloat(value, 'E', -1, 64)
Expand Down

0 comments on commit 919d54d

Please sign in to comment.