Utilities for a JSON-based API.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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