Utilities for a JSON-based API.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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