Code cleanup (#50)

This commit is contained in:
Connor Prussin 2017-07-20 15:48:59 -07:00 committed by GitHub
parent 930130b624
commit 008924e861
4 changed files with 41 additions and 33 deletions

View File

@ -25,7 +25,7 @@ read request = Aff.makeAff \_ success -> do
let stream = HTTP.requestAsStream request
buf <- ST.newSTRef ""
Stream.onDataString stream Encoding.UTF8 \str ->
ST.modifySTRef buf (\old -> old <> str) >>= (\_ -> pure unit)
ST.modifySTRef buf ((<>) str) >>= \_ -> pure unit
Stream.onEnd stream $ ST.readSTRef buf >>= success
-- | Write a body to the given HTTP Response and close it.

View File

@ -67,7 +67,9 @@ fromHTTPRequestSpec = Spec.describe "fromHTTPRequest" do
response <- mock "POST" "" "test" StrMap.empty
case response of
(Request.Post _ _ "test") -> pure unit
a -> Assertions.fail $ "expected the body 'test', got " <> show a
(Request.Post _ _ body) ->
Assertions.fail $ "expected the body 'test', got " <> body
a -> Assertions.fail $ "expected a post, got " <> show a
Spec.describe "with a PUT" do
Spec.it "is a Put" do
@ -90,7 +92,9 @@ fromHTTPRequestSpec = Spec.describe "fromHTTPRequest" do
response <- mock "PUT" "" "test" StrMap.empty
case response of
(Request.Put _ _ "test") -> pure unit
a -> Assertions.fail $ "expected the body 'test', got " <> show a
(Request.Put _ _ body) ->
Assertions.fail $ "expected the body 'test', got " <> body
a -> Assertions.fail $ "expected a put, got " <> show a
Spec.describe "with a DELETE" do
Spec.it "is a Delete" do
@ -149,7 +153,9 @@ fromHTTPRequestSpec = Spec.describe "fromHTTPRequest" do
response <- mock "CONNECT" "" "test" StrMap.empty
case response of
(Request.Connect _ _ "test") -> pure unit
a -> Assertions.fail $ "expected the body 'test', got " <> show a
(Request.Connect _ _ body) ->
Assertions.fail $ "expected the body 'test', got " <> body
a -> Assertions.fail $ "expected a connect, got " <> show a
Spec.describe "with a OPTIONS" do
Spec.it "is a Options" do
@ -208,7 +214,9 @@ fromHTTPRequestSpec = Spec.describe "fromHTTPRequest" do
response <- mock "PATCH" "" "test" StrMap.empty
case response of
(Request.Patch _ _ "test") -> pure unit
a -> Assertions.fail $ "expected the body 'test', got " <> show a
(Request.Patch _ _ body) ->
Assertions.fail $ "expected the body 'test', got " <> body
a -> Assertions.fail $ "expected a patch, got " <> show a
Spec.describe "with a GET" do
Spec.it "is a Get" do

View File

@ -100,7 +100,7 @@ post :: forall e.
String ->
String ->
Aff.Aff (HTTPRequestEffects e) String
post port headers path body = request port "POST" headers path body >>= toString
post port headers path = request port "POST" headers path >=> toString
-- | Convert a request to an Aff containing the string with the given header
-- | value.