Skip to content

Commit 5528e4f

Browse files
committed
fix: content-type utf8 jsson
1 parent c51388e commit 5528e4f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

api_v1.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"net/http"
88
"strconv"
9+
"strings"
910
"time"
1011

1112
"github.com/labstack/echo/v4"
@@ -209,7 +210,7 @@ func v1_insert_item(c echo.Context) error {
209210

210211
var item_id_type, item_status, item_status_type, payload string
211212

212-
if c.Request().Header.Get(echo.HeaderContentType) == echo.MIMEApplicationJSON {
213+
if strings.HasPrefix(strings.ToLower(c.Request().Header.Get(echo.HeaderContentType)), echo.MIMEApplicationJSON) {
213214
item := Item{}
214215
if err := c.Bind(&item); err != nil {
215216
return c.JSON(http.StatusBadRequest, echo.Map{"error": err.Error()})
@@ -262,7 +263,7 @@ func v1_insert_item(c echo.Context) error {
262263
}
263264
document[ID] = item_id_int
264265
default:
265-
return c.JSON(http.StatusBadRequest, echo.Map{"error": "Invalid task_id_type"})
266+
return c.JSON(http.StatusBadRequest, echo.Map{"error": "Invalid task_id_type", "item_id_type": item_id_type})
266267
}
267268
// status
268269
switch item_status_type {

0 commit comments

Comments
 (0)