Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/byteally/webapi
Browse files Browse the repository at this point in the history
  • Loading branch information
ersran9 committed Apr 20, 2016
2 parents 3a90c48 + ab05c27 commit 90e971e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions tests/WebApi/MockSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ withApp = with (return mockApp)
mockApp :: Wai.Application
mockApp = mockServer serverSettings (MockServer mockServerSettings :: MockServer MockSpec)

data MockSpec = MockSpec
data MockSpec

type MockApi = Static "mock"

data QP = QP { qp1 :: Int, qp2 :: Bool }
data QP = QP { _qp1 :: Int, _qp2 :: Bool }
deriving (Show, Eq, Generic)

data MockOut = MockOut { out1 :: Int
, out2 :: Bool
, out3 :: Char
data MockOut = MockOut { _out1 :: Int
, _out2 :: Bool
, _out3 :: Char
} deriving (Show, Eq, Generic)

instance ToJSON MockOut where
Expand Down
20 changes: 10 additions & 10 deletions tests/WebApi/RequestSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ newtype Age = Age { unAge :: Int }
deriving (Show, Eq, Generic)
-}

data QP = QP { qp1 :: Int , qp2 :: Maybe Bool, qp3 :: Either Text Double }
data QP = QP { _qp1 :: Int , _qp2 :: Maybe Bool, _qp3 :: Either Text Double }
deriving (Show, Eq, Generic)

data FoP = FoP { fop :: ByteString }
data FoP = FoP { _fop :: ByteString }
deriving (Show, Eq, Generic)

data CP = CP { cp :: Bool }
data CP = CP { _cp :: Bool }
deriving (Show, Eq, Generic)

data HP = HP1 { hp1 :: Int }
| HP2 { hp2 :: Bool }
data HP = HP1 { _hp1 :: Int }
| HP2 { _hp2 :: Bool }
deriving (Show, Eq, Generic)

data FiP = FiP { fip :: FileInfo }
data FiP = FiP { _fip :: FileInfo }
deriving (Show, Eq, Generic)

data RB = RB { rb :: Text }
data RB = RB { _rb :: Text }
deriving (Show, Eq, Generic)

instance FromParam QP 'QueryParam where
Expand Down Expand Up @@ -175,9 +175,9 @@ instance ApiHandler ReqSpecImpl OPTIONS ApiR where
handler _ _ = respond ["GET", "POST"]

formHeaders :: [(ByteString, ByteString)] -> [(ByteString, ByteString)] -> [Header]
formHeaders headerKvs cookieKvs = map toHeader headerKvs <> [toCookie cookieKvs]
where toHeader (k, v) = (mk k, v)
toCookie kvs = (hCookie, serializeCookie kvs)
formHeaders headerKvs cookieKvs = map toHeader' headerKvs <> [toCookie' cookieKvs]
where toHeader' (k, v) = (mk k, v)
toCookie' kvs = (hCookie, serializeCookie kvs)

serializeCookie = foldl' (\acc (k, v) -> acc <> ";" <> k <> "=" <> v) ""

Expand Down
8 changes: 4 additions & 4 deletions tests/WebApi/ResponseSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ respSpecApp = serverApp serverSettings RespSpecImpl
data RespSpec
data RespSpecImpl = RespSpecImpl

data Out = Out { out :: Text }
data Out = Out { _out :: Text }
deriving (Show, Eq, Generic)
data HOut = HOut { hOut :: Text }
data HOut = HOut { _hOut :: Text }
deriving (Show, Eq, Generic)
data COut = COut { cOut :: Text }
data COut = COut { _cOut :: Text }
deriving (Show, Eq, Generic)
data Err = Err { err :: Text }
data Err = Err { _err :: Text }
deriving (Show, Eq, Generic)

instance ToJSON Err
Expand Down

0 comments on commit 90e971e

Please sign in to comment.