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. }