Merge pull request #779 from writefreely/fix-ld-json-response-2
Correctly respond to application/ld+json requests, part 2
This commit is contained in:
commit
4aad0338bf
3 changed files with 3 additions and 3 deletions
|
@ -874,7 +874,7 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serve ActivityStreams data now, if requested
|
// Serve ActivityStreams data now, if requested
|
||||||
if strings.Contains(r.Header.Get("Accept"), "application/activity+json") {
|
if IsActivityPubRequest(r) {
|
||||||
ac := c.PersonObject()
|
ac := c.PersonObject()
|
||||||
ac.Context = []interface{}{activitystreams.Namespace}
|
ac.Context = []interface{}{activitystreams.Namespace}
|
||||||
setCacheControl(w, apCacheTime)
|
setCacheControl(w, apCacheTime)
|
||||||
|
|
|
@ -818,7 +818,7 @@ func (h *Handler) handleHTTPError(w http.ResponseWriter, r *http.Request, err er
|
||||||
return
|
return
|
||||||
} else if err.Status == http.StatusNotFound {
|
} else if err.Status == http.StatusNotFound {
|
||||||
w.WriteHeader(err.Status)
|
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
|
// This is a fediverse request; simply return the header
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
2
posts.go
2
posts.go
|
@ -1546,7 +1546,7 @@ Are you sure it was ever here?`,
|
||||||
fmt.Fprintf(w, "# %s\n\n", p.Title.String)
|
fmt.Fprintf(w, "# %s\n\n", p.Title.String)
|
||||||
}
|
}
|
||||||
fmt.Fprint(w, p.Content)
|
fmt.Fprint(w, p.Content)
|
||||||
} else if strings.Contains(r.Header.Get("Accept"), "application/activity+json") {
|
} else if IsActivityPubRequest(r) {
|
||||||
if !postFound {
|
if !postFound {
|
||||||
return ErrCollectionPageNotFound
|
return ErrCollectionPageNotFound
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue