Utilities for a JSON-based API.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

14 lignes
312 B

  1. package impart
  2. import (
  3. "mime"
  4. "net/http"
  5. )
  6. // ReqJSON returns whether or not the given Request is sending JSON, based on
  7. // the Content-Type header being application/json.
  8. func ReqJSON(r *http.Request) bool {
  9. ct, _, _ := mime.ParseMediaType(r.Header.Get("Content-Type"))
  10. return ct == "application/json"
  11. }