From 496cd775107bffdefdd1e74fd0be6be2b877f15e Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Wed, 18 Nov 2015 23:56:59 -0800 Subject: [PATCH] More docs for pickContentType --- src/PostgREST/RequestIntent.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PostgREST/RequestIntent.hs b/src/PostgREST/RequestIntent.hs index 50c07428d..a8e56eb94 100644 --- a/src/PostgREST/RequestIntent.hs +++ b/src/PostgREST/RequestIntent.hs @@ -112,8 +112,14 @@ userIntent schema req reqBody = -- PRIVATE --------------------------------------------------------------- --- | Chooses a payload from the items in an accept header. --- When possible it picks JSON. +-- | Picks a preferred content type from an Accept header (or from +-- Content-Type as a degenerate case). +-- +-- For example +-- text/csv -> TextCSV +-- */* -> ApplicationJSON +-- text/csv, application/json -> TextCSV +-- application/json, text/csv -> ApplicationJSON pickContentType :: Maybe BS.ByteString -> Either BS.ByteString ContentType pickContentType accept | isNothing accept || has ctAll || has ctJson = Right ApplicationJSON