Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type RequestBody = ByteString
- data Action
- data Target
- data PreferRepresentation
- = Full
- | HeadersOnly
- | None
- data ContentType
- data ApiRequest = ApiRequest {
- iAction :: Action
- iRange :: HashMap String NonnegRange
- iTarget :: Target
- iAccepts :: Either ByteString ContentType
- iPayload :: Maybe Payload
- iPreferRepresentation :: PreferRepresentation
- iPreferSingular :: Bool
- iPreferCount :: Bool
- iFilters :: [(String, String)]
- iSelect :: String
- iOrder :: [(String, String)]
- iCanonicalQS :: String
- iJWT :: Text
- userApiRequest :: Schema -> Request -> RequestBody -> ApiRequest
- pickContentType :: Maybe ByteString -> Either ByteString ContentType
- type CsvData = Vector (HashMap Text ByteString)
- csvToJson :: (Header, CsvData) -> Array
- pluralize :: Value -> Array
- ensureUniform :: Array -> Maybe UniformObjects
Documentation
type RequestBody = ByteString Source #
Types of things a user wants to do to tablesviewsprocs
The target db object of a user action
data PreferRepresentation Source #
How to return the inserted data
data ContentType Source #
Enumeration of currently supported content types for route responses and upload payloads
data ApiRequest Source #
Describes what the user wants to do. This data type is a translation of the raw elements of an HTTP request into domain specific language. There is no guarantee that the intent is sensible, it is up to a later stage of processing to determine if it is an action we are able to perform.
ApiRequest | |
|
userApiRequest :: Schema -> Request -> RequestBody -> ApiRequest Source #
Examines HTTP request and translates it into user intent.
pickContentType :: Maybe ByteString -> Either ByteString ContentType Source #
Picks a preferred content type from an Accept header (or from Content-Type as a degenerate case).
For example text/csv -> TextCSV */* -> ApplicationJSON textcsv, applicationjson -> TextCSV applicationjson, textcsv -> ApplicationJSON
csvToJson :: (Header, CsvData) -> Array Source #
Converts CSV like a,b 1,hi 2,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
pluralize :: Value -> Array Source #
Convert {foo} to [{foo}], leave arrays unchanged and truncate everything else to an empty array.
ensureUniform :: Array -> Maybe UniformObjects Source #
Test that Array contains only Objects having the same keys and if so mark it as UniformObjects