mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-06 02:33:22 -06:00
[bugfix] Serve correct 'application/jrd+json' content type for webfinger requests (#1738)
* [bugfix] Return `application/jrd+json` from webfinger queries * update finger req content-type
This commit is contained in:
parent
4a012acd52
commit
5027d0ced2
7 changed files with 128 additions and 161 deletions
|
|
@ -18,6 +18,7 @@
|
|||
package webfinger
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
|
@ -48,14 +49,14 @@ import (
|
|||
// - .well-known
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/jrd+json
|
||||
//
|
||||
// responses:
|
||||
// '200':
|
||||
// schema:
|
||||
// "$ref": "#/definitions/wellKnownResponse"
|
||||
func (m *Module) WebfingerGETRequest(c *gin.Context) {
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil {
|
||||
if _, err := apiutil.NegotiateAccept(c, apiutil.WebfingerJSONAcceptHeaders...); err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
|
@ -86,5 +87,13 @@ func (m *Module) WebfingerGETRequest(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
b, err := json.Marshal(resp)
|
||||
if err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorInternalError(err), m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
// Always return "application/jrd+json" regardless of negotiated
|
||||
// format. See https://www.rfc-editor.org/rfc/rfc7033#section-10.2
|
||||
c.Data(http.StatusOK, string(apiutil.AppJRDJSON), b)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue