summaryrefslogtreecommitdiff
path: root/internal/api/util
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/util')
-rw-r--r--internal/api/util/mime.go2
-rw-r--r--internal/api/util/response.go13
2 files changed, 15 insertions, 0 deletions
diff --git a/internal/api/util/mime.go b/internal/api/util/mime.go
index da96be786..6159d4b79 100644
--- a/internal/api/util/mime.go
+++ b/internal/api/util/mime.go
@@ -26,6 +26,8 @@ const (
appXMLText = `text/xml` // AppXML is only *recommended* in RFC7303
AppXMLXRD = `application/xrd+xml`
AppRSSXML = `application/rss+xml`
+ AppAtomXML = `application/atom+xml`
+ AppFeedJSON = `application/feed+json`
AppActivityJSON = `application/activity+json`
appActivityLDJSON = `application/ld+json` // without profile
AppActivityLDJSON = appActivityLDJSON + `; profile="https://www.w3.org/ns/activitystreams"`
diff --git a/internal/api/util/response.go b/internal/api/util/response.go
index 105537f36..ff58b68e3 100644
--- a/internal/api/util/response.go
+++ b/internal/api/util/response.go
@@ -71,6 +71,18 @@ func JSONType(c *gin.Context, code int, contentType string, data any) {
EncodeJSONResponse(c.Writer, c.Request, code, contentType, data)
}
+// XML calls EncodeJSONResponse() using gin.Context{}, with content-type = AppXML,
+// This function handles the case of XML unmarshal errors and pools read buffers.
+func XML(c *gin.Context, code int, data any) {
+ EncodeXMLResponse(c.Writer, c.Request, code, AppXML, data)
+}
+
+// XML calls EncodeXMLResponse() using gin.Context{}, with given content-type.
+// This function handles the case of XML unmarshal errors and pools read buffers.
+func XMLType(c *gin.Context, code int, contentType string, data any) {
+ EncodeXMLResponse(c.Writer, c.Request, code, contentType, data)
+}
+
// Data calls WriteResponseBytes() using gin.Context{}, with given content-type.
func Data(c *gin.Context, code int, contentType string, data []byte) {
WriteResponseBytes(c.Writer, c.Request, code, contentType, data)
@@ -230,6 +242,7 @@ func EncodeCSVResponse(
// Write all the records to the buffer.
if err := csvWriter.WriteAll(records); err == nil {
+
// Respond with the now-known
// size byte slice within buf.
WriteResponseBytes(rw, r,