chore(go): use json instead of jsonapi

This commit is contained in:
email
2022-02-04 16:51:48 +08:00
parent a8f0c9a7b1
commit d6418f5ff9
16 changed files with 131 additions and 109 deletions

View File

@ -1,13 +1,13 @@
package server
import (
"encoding/json"
"fmt"
"io/ioutil"
"memos/api"
"net/http"
"strconv"
"github.com/google/jsonapi"
"github.com/labstack/echo/v4"
)
@ -53,7 +53,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
}
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
if err := jsonapi.MarshalPayload(c.Response().Writer, resource); err != nil {
if err := json.NewEncoder(c.Response().Writer).Encode(resource); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal shortcut response").SetInternal(err)
}
@ -70,7 +70,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
}
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
if err := jsonapi.MarshalPayload(c.Response().Writer, list); err != nil {
if err := json.NewEncoder(c.Response().Writer).Encode(list); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal resource list response").SetInternal(err)
}