github 0.3.0 → 0.4.0
raw patch · 3 files changed
+22/−23 lines, 3 filesdep +conduitdep −tlsdep −tls-extradep ~http-conduitPVP ok
version bump matches the API change (PVP)
Dependencies added: conduit
Dependencies removed: tls, tls-extra
Dependency ranges changed: http-conduit
API changes (from Hackage documentation)
Files
- Github/Private.hs +11/−11
- Github/Repos/Collaborators.hs +8/−8
- github.cabal +3/−4
Github/Private.hs view
@@ -8,8 +8,9 @@ import Data.List import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Lazy.Char8 as LBS-import Network.HTTP.Types (Method)+import Network.HTTP.Types (Method, Status(..)) import Network.HTTP.Conduit+import Data.Conduit (ResourceT) import Text.URI import qualified Control.Exception as E import Data.Maybe (fromMaybe)@@ -62,19 +63,15 @@ -- | user/password for HTTP basic access authentication type BasicAuth = (BS.ByteString, BS.ByteString) -doHttps :: Method -> String -> Maybe BasicAuth -> Maybe (RequestBody IO) -> IO (Either E.SomeException (Response LBS.ByteString))+doHttps :: Method -> String -> Maybe BasicAuth -> Maybe (RequestBody (ResourceT IO)) -> IO (Either E.SomeException (Response LBS.ByteString)) doHttps method url auth body = do- let (Just uri) = parseURI url- (Just host) = uriRegName uri- requestBody = fromMaybe (RequestBodyBS $ BS.pack "") body- queryString = BS.pack $ fromMaybe "" $ uriQuery uri- request = def { method = method+ let requestBody = fromMaybe (RequestBodyBS $ BS.pack "") body+ (Just uri) = parseUrl url+ request = uri { method = method , secure = True- , host = BS.pack host , port = 443- , path = BS.pack $ uriPath uri , requestBody = requestBody- , queryString = queryString+ , checkStatus = successOrMissing } authRequest = maybe id (uncurry applyBasicAuth) auth request @@ -84,11 +81,14 @@ -- UserInterrupt) because all of them indicate severe conditions and -- should not occur during normal operation. E.Handler (\e -> E.throw (e :: E.AsyncException)),-+ E.Handler (\e -> (return . Left) (e :: E.SomeException)) ] where getResponse request = withManager $ \manager -> httpLbs request manager+ successOrMissing s@(Status sci _) hs+ | (200 <= sci && sci < 300) || sci == 404 = Nothing+ | otherwise = Just $ E.toException $ StatusCodeException s hs parseJson :: (FromJSON b, Show b) => LBS.ByteString -> Either Error b parseJson jsonString =
Github/Repos/Collaborators.hs view
@@ -10,7 +10,7 @@ import Github.Private import Data.ByteString.Char8 (pack)-import qualified Network.HTTP.Conduit as C (statusCode)+import qualified Network.HTTP.Conduit as C (responseStatus) import qualified Network.HTTP.Types as T (statusCode) -- | All the users who have collaborated on a repo.@@ -27,10 +27,10 @@ -- > isCollaboratorOn "johnson" "thoughtbot" "paperclip" isCollaboratorOn :: String -> String -> String -> IO (Either Error Bool) isCollaboratorOn userName repoOwnerName repoName = do- result <- doHttps (pack "GET")- (buildUrl ["repos", repoOwnerName, repoName, "collaborators", userName])- Nothing- Nothing- return $ either (Left . HTTPConnectionError)- (Right . (204 ==) . T.statusCode . C.statusCode)- result+ result <- doHttps (pack "GET")+ (buildUrl ["repos", repoOwnerName, repoName, "collaborators", userName])+ Nothing+ Nothing+ return $ either (Left . HTTPConnectionError)+ (Right . (204 ==) . T.statusCode . C.responseStatus)+ result
github.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.3.0+Version: 0.4.0 -- A short (one-line) description of the package. Synopsis: Access to the Github API, v3.@@ -148,9 +148,8 @@ old-locale, HTTP, network,- tls == 0.9.2,- tls-extra == 0.4.4,- http-conduit == 1.2.6,+ http-conduit == 1.4.1.10,+ conduit, uri, failure, http-types,