Skip to content

Commit 95aad98

Browse files
author
Anthony Wang
committed
Use ctx.JSON in Person response to make code cleaner
1 parent e5ed91d commit 95aad98

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

routers/api/v1/activitypub/person.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,9 @@ func Person(ctx *context.APIContext) {
8484
ctx.Error(http.StatusInternalServerError, "Unmarshal", err)
8585
return
8686
}
87-
8887
jsonmap["@context"] = []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"}
89-
90-
ctx.Resp.Header().Add("Content-Type", "application/activity+json")
91-
ctx.Resp.WriteHeader(http.StatusOK)
92-
binary, err = json.Marshal(jsonmap)
93-
if err != nil {
94-
ctx.Error(http.StatusInternalServerError, "Marshal", err)
95-
return
96-
}
97-
if _, err = ctx.Resp.Write(binary); err != nil {
98-
log.Error("write to resp err: %v", err)
99-
}
88+
ctx.JSON(http.StatusOK, jsonmap)
89+
ctx.Resp.Header().Set("Content-Type", activitypub.ActivityStreamsContentType)
10090
}
10191

10292
// PersonInbox function

0 commit comments

Comments
 (0)