A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

30 lines
788 B

  1. /*
  2. * Copyright © 2018 Musing Studio LLC.
  3. *
  4. * This file is part of WriteFreely.
  5. *
  6. * WriteFreely is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License, included
  8. * in the LICENSE file in this source code package.
  9. */
  10. package writefreely
  11. import (
  12. "mime"
  13. "net/http"
  14. "strings"
  15. )
  16. func IsJSON(r *http.Request) bool {
  17. ct, _, _ := mime.ParseMediaType(r.Header.Get("Content-Type"))
  18. accept := r.Header.Get("Accept")
  19. return ct == "application/json" || accept == "application/json"
  20. }
  21. func IsActivityPubRequest(r *http.Request) bool {
  22. accept := r.Header.Get("Accept")
  23. return strings.Contains(accept, "application/activity+json") ||
  24. accept == "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
  25. }