Utilities for a JSON-based API.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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