packages feed

restman-0.7.4.0: app/TUI.hs

{-# language DeriveGeneric #-}
{-|
Module: TUI

Legacy type definitions retained from the original project scaffold.

'Verb' and 'ReqConfig' were the initial design for the HTTP request abstraction.  They are
not currently used by the main application — see "HTTP.Client" and "Types" for the types
in active use.
-}
module TUI where

-- ghc
import GHC.Generics (Generic)

-- text
import Data.Text as T

-- wreq
import Network.Wreq (Options)

-- | Supported HTTP verbs, including an escape hatch for non-standard methods.
data Verb
  = GET     -- ^ HTTP GET
  | HEAD    -- ^ HTTP HEAD
  | POST    -- ^ HTTP POST
  | PUT     -- ^ HTTP PUT
  | DELETE  -- ^ HTTP DELETE
  | OPTIONS -- ^ HTTP OPTIONS
  | PATCH   -- ^ HTTP PATCH
  | Custom T.Text -- ^ Any non-standard method name.
  deriving (Show, Eq, Generic)

{-|
Configuration for a single HTTP request.

Bundles together the target URI, the wreq 'Options' (headers, auth, etc.), and the HTTP
verb to use.
-}
data ReqConfig =
  ReqConfig
    { _httpUri :: T.Text    -- ^ The request target URI.
    , _options :: Options   -- ^ wreq request options (headers, authentication, etc.).
    , _verb :: Verb         -- ^ The HTTP verb for the request.
    } deriving (Show, Generic)