postgrest-0.3.2.0: REST API for any Postgres database

Safe HaskellNone
LanguageHaskell2010

PostgREST.ApiRequest

Synopsis

Documentation

data Action Source #

Types of things a user wants to do to tablesviewsprocs

Instances

Eq Action Source # 

Methods

(==) :: Action -> Action -> Bool #

(/=) :: Action -> Action -> Bool #

data Target Source #

The target db object of a user action

data ContentType Source #

Enumeration of currently supported content types for route responses and upload payloads

Constructors

ApplicationJSON 
TextCSV 

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.

Constructors

ApiRequest 

Fields

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