Skip to content

Commit 0ede402

Browse files
committed
sjson pt type
1 parent 80f0a4c commit 0ede402

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

internal/api/handlers/device_definition_handler.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package handlers
22

33
import (
4+
"github.com/tidwall/sjson"
45
"strconv"
56
"strings"
67

@@ -128,12 +129,21 @@ func VINProfile(m mediator.Mediator) fiber.Handler {
128129
Type: "https://tools.ietf.org/html/rfc7231#section-6.5.1",
129130
Title: "No VIN profile founder",
130131
Status: fiber.StatusNotFound,
131-
Detail: "Couldn't get VIN profile.",
132+
Detail: err.Error(),
132133
})
133134
}
134135
resp := result.(*queries.GetVINProfileResponse)
135136
c.Type("json") // sets Content-Type: application/json
136-
return c.Send(resp.ProfileRaw)
137+
jb, err := sjson.SetBytes(resp.ProfileRaw, "powertrainType", resp.PowertrainType)
138+
if err != nil {
139+
return c.Status(fiber.StatusInternalServerError).JSON(common.ProblemDetails{
140+
Type: "https://tools.ietf.org/html/rfc7231#section-6.5.1",
141+
Title: "Failed to set powertrainType",
142+
Status: fiber.StatusInternalServerError,
143+
Detail: err.Error(),
144+
})
145+
}
146+
return c.Send(jb)
137147
}
138148
}
139149

0 commit comments

Comments
 (0)