@@ -3,7 +3,8 @@ module Http
33 ( Manager
44 , getManager
55 , toUrl
6− -- post
6+ -- fetch
7+ , get
78 , post
89 , Header
910 , accept
@@ -11,7 +12,7 @@ module Http
1112 -- archives
1213 , Sha
1314 , shaToChars
14− , fetchArchive
15+ , getArchive
1516 -- upload
1617 , upload
1718 , filePart
@@ -32,7 +33,7 @@ import Network.HTTP (urlEncodeVars)
3233import Network.HTTP.Client
3334import Network.HTTP.Client.TLS (tlsManagerSettings)
3435import Network.HTTP.Types.Header (Header, hAccept, hAcceptEncoding, hUserAgent)
35−import Network.HTTP.Types.Method (methodPost)
36+import Network.HTTP.Types.Method (Method, methodGet, methodPost)
3637import qualified Network.HTTP.Client.MultipartFormData as Multi
3738
3839import qualified Elm.Version as V
@@ -59,17 +60,27 @@ toUrl url params =
5960
6061
6162
62−-- POST
63+-- FETCH
64+
65+
66+get :: Manager -> String -> [Header] -> (Error -> e) -> (BS.ByteString -> IO (Either e a)) -> IO (Either e a)
67+get =
68+ fetch methodGet
6369
6470
6571post :: Manager -> String -> [Header] -> (Error -> e) -> (BS.ByteString -> IO (Either e a)) -> IO (Either e a)
66−post manager url headers onError onSuccess =
72+post =
73+ fetch methodPost
74+
75+
76+fetch :: Method -> Manager -> String -> [Header] -> (Error -> e) -> (BS.ByteString -> IO (Either e a)) -> IO (Either e a)
77+fetch methodVerb manager url headers onError onSuccess =
6778 handle (handleSomeException url onError) $
6879 handle (handleHttpException url onError) $
6980 do req0 <- parseUrlThrow url
7081 let req1 =
7182 req0
72− { method = methodPost
83+ { method = methodVerb
7384 , requestHeaders = addDefaultHeaders headers
7485 }
7586 withResponse req1 manager $ \response ->
@@ -134,20 +145,20 @@ shaToChars =
134145-- FETCH ARCHIVE
135146
136147
137−fetchArchive
148+getArchive
138149 :: Manager
139150 -> String
140151 -> (Error -> e)
141152 -> e
142153 -> ((Sha, Zip.Archive) -> IO (Either e a))
143154 -> IO (Either e a)
144−fetchArchive manager url onError err onSuccess =
155+getArchive manager url onError err onSuccess =
145156 handle (handleSomeException url onError) $
146157 handle (handleHttpException url onError) $
147158 do req0 <- parseUrlThrow url
148159 let req1 =
149160 req0
150− { method = methodPost
161+ { method = methodGet
151162 , requestHeaders = addDefaultHeaders []
152163 }
153164 withResponse req1 manager $ \response ->