module Mongrel2.Types
       ( ClientID
       , Connection(..)
       , Request(..)
       , UUID
       ) where

import Data.ByteString (ByteString)
import Data.Int (Int64)
import Data.Text (Text)
import Network.HTTP.Types (Ascii, HttpVersion, RequestHeaders, StdMethod, Query)

-- | Client identifier from Mongrel2. This identifies the currently
-- connected client uniquely.
type ClientID = Int64

-- | UUID for communicating with Mongrel2.
type UUID = ByteString

-- | Connection information.
data Connection = Connection {
  -- | UUID of the connected Mongrel2 server.
  connServerUUID :: UUID,
  -- | ID of the connected client browser.
  connClientID :: ClientID
} deriving (Show)

-- | Request information.
data Request = Request {
  -- | Request path
  reqPath :: [Text],
  -- | Query part of the request
  reqQuery :: Query,
  -- | Raw request path including query part.
  reqRawPath :: ByteString,
  -- | Request method (GET, POST, etc.)
  reqMethod :: Either Ascii StdMethod,
  -- | HTTP version
  reqVersion :: Maybe HttpVersion,
  -- | Request headers
  reqHeaders :: RequestHeaders,
  -- | Request body.
  reqBody :: ByteString
  } deriving (Show)