A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

23 行
539 B

  1. /*
  2. * Copyright © 2018 A Bunch Tell 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. )
  15. func IsJSON(r *http.Request) bool {
  16. ct, _, _ := mime.ParseMediaType(r.Header.Get("Content-Type"))
  17. accept := r.Header.Get("Accept")
  18. return ct == "application/json" || accept == "application/json"
  19. }