From 95aad988975be3393c76094864ed6ba962157e0c Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Wed, 15 Jun 2022 20:22:05 -0500 Subject: [PATCH] Use ctx.JSON in Person response to make code cleaner --- routers/api/v1/activitypub/person.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go index 7b1212fa73..71b646dbb5 100644 --- a/routers/api/v1/activitypub/person.go +++ b/routers/api/v1/activitypub/person.go @@ -84,19 +84,9 @@ func Person(ctx *context.APIContext) { ctx.Error(http.StatusInternalServerError, "Unmarshal", err) return } - jsonmap["@context"] = []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"} - - ctx.Resp.Header().Add("Content-Type", "application/activity+json") - ctx.Resp.WriteHeader(http.StatusOK) - binary, err = json.Marshal(jsonmap) - if err != nil { - ctx.Error(http.StatusInternalServerError, "Marshal", err) - return - } - if _, err = ctx.Resp.Write(binary); err != nil { - log.Error("write to resp err: %v", err) - } + ctx.JSON(http.StatusOK, jsonmap) + ctx.Resp.Header().Set("Content-Type", activitypub.ActivityStreamsContentType) } // PersonInbox function