postgrest-0.4.2.0: REST API for any Postgres database

Safe Haskell | None
Language | Haskell2010

PostgREST.ApiRequest

Description

Synopsis

- data ApiRequest = ApiRequest {
  - iAction :: Action
  - iRange :: HashMap ByteString NonnegRange
  - iTarget :: Target
  - iAccepts :: [ContentType]
  - iPayload :: Maybe PayloadJSON
  - iPreferRepresentation :: PreferRepresentation
  - iPreferSingleObjectParameter :: Bool
  - iPreferCount :: Bool
  - iFilters :: [(Text, Text)]
  - iLogic :: [(Text, Text)]
  - iSelect :: Text
  - iOrder :: [(Text, Text)]
  - iCanonicalQS :: ByteString
  - iJWT :: Text
  - iHeaders :: [(Text, Text)]
  - iCookies :: [(Text, Text)]
  }
- data ContentType
  - = CTApplicationJSON
  - | CTTextCSV
  - | CTOpenAPI
  - | CTSingularJSON
  - | CTOctetStream
  - | CTAny
  - | CTOther ByteString
- data Action
  - = ActionCreate
  - | ActionRead
  - | ActionUpdate
  - | ActionDelete
  - | ActionInfo
  - | ActionInvoke
  - | ActionInspect
- data Target
  - = TargetIdent QualifiedIdentifier
  - | TargetProc QualifiedIdentifier
  - | TargetRoot
  - | TargetUnknown [Text]
- data PreferRepresentation
  - = Full
  - | HeadersOnly
  - | None
- mutuallyAgreeable :: [ContentType] -> [ContentType] -> Maybe ContentType
- userApiRequest :: Schema -> Request -> RequestBody -> Either ApiRequestError ApiRequest

# Documentation

data ApiRequest #

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 iAction :: Action Similar but not identical to HTTP verb, e.g. Create/Invoke both POST iRange :: HashMap ByteString NonnegRange Requested range of rows within response iTarget :: Target The target, be it calling a proc or accessing a table iAccepts :: [ContentType] Content types the client will accept, [CTAny] if no Accept header iPayload :: Maybe PayloadJSON Data sent by client and used for mutation actions iPreferRepresentation :: PreferRepresentation If client wants created items echoed back iPreferSingleObjectParameter :: Bool Pass all parameters as a single json object to a stored procedure iPreferCount :: Bool Whether the client wants a result count (slower) iFilters :: [(Text, Text)] Filters on the result ("id", "eq.10") iLogic :: [(Text, Text)] &and and &or parameters used for complex boolean logic iSelect :: Text &select parameter used to shape the response iOrder :: [(Text, Text)] &order parameters for each level iCanonicalQS :: ByteString Alphabetized (canonical) request query string for response URLs iJWT :: Text JSON Web Token iHeaders :: [(Text, Text)] HTTP request headers iCookies :: [(Text, Text)] Request Cookies

data ContentType #

Enumeration of currently supported response content types

Constructors

CTApplicationJSON |
CTTextCSV |
CTOpenAPI |
CTSingularJSON |
CTOctetStream |
CTAny |
CTOther ByteString |

Instances

Eq ContentType # |
Methods (==) :: ContentType -> ContentType -> Bool # (/=) :: ContentType -> ContentType -> Bool #

data Action #

Types of things a user wants to do to tablesviewsprocs

Constructors

ActionCreate |
ActionRead |
ActionUpdate |
ActionDelete |
ActionInfo |
ActionInvoke |
ActionInspect |

Instances

Eq Action # |
Methods (==) :: Action -> Action -> Bool # (/=) :: Action -> Action -> Bool #

data Target #

The target db object of a user action

Constructors

TargetIdent QualifiedIdentifier |
TargetProc QualifiedIdentifier |
TargetRoot |
TargetUnknown [Text] |

Instances

Eq Target # |
Methods (==) :: Target -> Target -> Bool # (/=) :: Target -> Target -> Bool #

data PreferRepresentation #

How to return the inserted data

Constructors

Full |
HeadersOnly |
None |

Instances

Eq PreferRepresentation # |
Methods (==) :: PreferRepresentation -> PreferRepresentation -> Bool # (/=) :: PreferRepresentation -> PreferRepresentation -> Bool #

mutuallyAgreeable :: [ContentType] -> [ContentType] -> Maybe ContentType #

Find the best match from a list of content types accepted by the client in order of decreasing preference and a list of types producible by the server. If there is no match but the client accepts */* then return the top server pick.

userApiRequest :: Schema -> Request -> RequestBody -> Either ApiRequestError ApiRequest #

Examines HTTP request and translates it into user intent.