Cool person style for long comments
This commit is contained in:
@@ -37,11 +37,13 @@ data ContentType = ApplicationJSON | TextCSV
|
|||||||
data Payload = PayloadJSON JSON.Array
|
data Payload = PayloadJSON JSON.Array
|
||||||
| PayloadParseError BS.ByteString
|
| PayloadParseError BS.ByteString
|
||||||
|
|
||||||
-- | Describes what the user wants to do. This data type is a
|
{-|
|
||||||
-- translation of the raw elements of an HTTP request into domain
|
Describes what the user wants to do. This data type is a
|
||||||
-- specific language. There is no guarantee that the intent is
|
translation of the raw elements of an HTTP request into domain
|
||||||
-- sensible, it is up to a later stage of processing to determine
|
specific language. There is no guarantee that the intent is
|
||||||
-- if it is an action we are able to perform.
|
sensible, it is up to a later stage of processing to determine
|
||||||
|
if it is an action we are able to perform.
|
||||||
|
-}
|
||||||
data Intent = Intent {
|
data Intent = Intent {
|
||||||
-- | Set to Nothing for unknown HTTP verbs
|
-- | Set to Nothing for unknown HTTP verbs
|
||||||
iAction :: Action
|
iAction :: Action
|
||||||
@@ -112,14 +114,16 @@ userIntent schema req reqBody =
|
|||||||
|
|
||||||
-- PRIVATE ---------------------------------------------------------------
|
-- PRIVATE ---------------------------------------------------------------
|
||||||
|
|
||||||
-- | Picks a preferred content type from an Accept header (or from
|
{-|
|
||||||
-- Content-Type as a degenerate case).
|
Picks a preferred content type from an Accept header (or from
|
||||||
--
|
Content-Type as a degenerate case).
|
||||||
-- For example
|
|
||||||
-- text/csv -> TextCSV
|
For example
|
||||||
-- */* -> ApplicationJSON
|
text/csv -> TextCSV
|
||||||
-- text/csv, application/json -> TextCSV
|
*/* -> ApplicationJSON
|
||||||
-- application/json, text/csv -> ApplicationJSON
|
text/csv, application/json -> TextCSV
|
||||||
|
application/json, text/csv -> ApplicationJSON
|
||||||
|
-}
|
||||||
pickContentType :: Maybe BS.ByteString -> Either BS.ByteString ContentType
|
pickContentType :: Maybe BS.ByteString -> Either BS.ByteString ContentType
|
||||||
pickContentType accept
|
pickContentType accept
|
||||||
| isNothing accept || has ctAll || has ctJson = Right ApplicationJSON
|
| isNothing accept || has ctAll || has ctJson = Right ApplicationJSON
|
||||||
@@ -135,16 +139,18 @@ pickContentType accept
|
|||||||
|
|
||||||
type CsvData = V.Vector (M.HashMap T.Text BL.ByteString)
|
type CsvData = V.Vector (M.HashMap T.Text BL.ByteString)
|
||||||
|
|
||||||
-- | Converts CSV like
|
{-|
|
||||||
-- a,b
|
Converts CSV like
|
||||||
-- 1,hi
|
a,b
|
||||||
-- 2,bye
|
1,hi
|
||||||
--
|
2,bye
|
||||||
-- into a JSON array like
|
|
||||||
-- [ {"a": "1", "b": "hi"}, {"a": 2, "b": "bye"} ]
|
into a JSON array like
|
||||||
--
|
[ {"a": "1", "b": "hi"}, {"a": 2, "b": "bye"} ]
|
||||||
-- The reason for its odd signature is so that it can compose
|
|
||||||
-- directly with CSV.decodeByName
|
The reason for its odd signature is so that it can compose
|
||||||
|
directly with CSV.decodeByName
|
||||||
|
-}
|
||||||
csvToJson :: (CSV.Header, CsvData) -> JSON.Array
|
csvToJson :: (CSV.Header, CsvData) -> JSON.Array
|
||||||
csvToJson (_, vals) =
|
csvToJson (_, vals) =
|
||||||
V.map rowToJsonObj vals
|
V.map rowToJsonObj vals
|
||||||
|
|||||||
Reference in New Issue
Block a user