mirror of
https://github.com/writefreely/writefreely
synced 2024-11-10 03:24:11 +00:00
Correctly respond to application/ld+json requests, part 2
This finishes the work started in #766, ensuring that requests to canonical URLs of blogs and posts (not just at their API endpoints) respond correctly to `application/ld+json;...` requests. Fully addresses issue #564
This commit is contained in:
parent
74f3ded250
commit
2275a288b9
3 changed files with 3 additions and 3 deletions
|
@ -853,7 +853,7 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
|
|||
}
|
||||
|
||||
// Serve ActivityStreams data now, if requested
|
||||
if strings.Contains(r.Header.Get("Accept"), "application/activity+json") {
|
||||
if IsActivityPubRequest(r) {
|
||||
ac := c.PersonObject()
|
||||
ac.Context = []interface{}{activitystreams.Namespace}
|
||||
setCacheControl(w, apCacheTime)
|
||||
|
|
|
@ -818,7 +818,7 @@ func (h *Handler) handleHTTPError(w http.ResponseWriter, r *http.Request, err er
|
|||
return
|
||||
} else if err.Status == http.StatusNotFound {
|
||||
w.WriteHeader(err.Status)
|
||||
if strings.Contains(r.Header.Get("Accept"), "application/activity+json") {
|
||||
if IsActivityPubRequest(r) {
|
||||
// This is a fediverse request; simply return the header
|
||||
return
|
||||
}
|
||||
|
|
2
posts.go
2
posts.go
|
@ -1520,7 +1520,7 @@ Are you sure it was ever here?`,
|
|||
fmt.Fprintf(w, "# %s\n\n", p.Title.String)
|
||||
}
|
||||
fmt.Fprint(w, p.Content)
|
||||
} else if strings.Contains(r.Header.Get("Accept"), "application/activity+json") {
|
||||
} else if IsActivityPubRequest(r) {
|
||||
if !postFound {
|
||||
return ErrCollectionPageNotFound
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue