diff --git a/app/Main.hs b/app/Main.hs index dd6ead2..417efbf 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,12 +1,10 @@ module Main where --- import qualified Network.HTTP.Conduit as NC - import Protolude -import Network.Minio.Data +import Network.Minio -import Network.Minio.API +-- import Network.Minio.S3API import Control.Monad.Trans.Resource (runResourceT) -- import qualified Data.Conduit as C -- import qualified Data.Conduit.List as CL diff --git a/minio-hs.cabal b/minio-hs.cabal index 8449f24..fe587ce 100644 --- a/minio-hs.cabal +++ b/minio-hs.cabal @@ -16,14 +16,16 @@ cabal-version: >=1.10 library hs-source-dirs: src ghc-options: -Wall - exposed-modules: Network.Minio.Data + exposed-modules: Network.Minio + , Network.Minio.S3API + other-modules: Lib.Prelude + , Network.Minio.Data , Network.Minio.Data.ByteString , Network.Minio.Data.Crypto , Network.Minio.Data.Time , Network.Minio.Sign.V4 , Network.Minio.API , Network.Minio.XmlParser - other-modules: Lib.Prelude build-depends: base >= 4.7 && < 5 , protolude >= 0.1.6 && < 0.2 , bytestring diff --git a/src/Network/Minio.hs b/src/Network/Minio.hs new file mode 100644 index 0000000..6ba2185 --- /dev/null +++ b/src/Network/Minio.hs @@ -0,0 +1,21 @@ +module Network.Minio + ( module Exports + ) where + +{- +This module exports the high-level Minio API for object storage. +-} + +import Network.Minio.S3API as + Exports ( + getService + , getLocation + ) + +import Network.Minio.Data as + Exports ( + runMinio + , defaultConnectInfo + , connect + , ConnectInfo(..) + ) diff --git a/src/Network/Minio/API.hs b/src/Network/Minio/API.hs index c652467..1391423 100644 --- a/src/Network/Minio/API.hs +++ b/src/Network/Minio/API.hs @@ -4,8 +4,8 @@ module Network.Minio.API , defaultConnectInfo , RequestInfo(..) , runMinio - , getService - , getLocation + , executeRequest + , requestInfo ) where import qualified Network.HTTP.Types as HT @@ -20,7 +20,6 @@ import qualified Data.Conduit as C import Network.Minio.Data import Network.Minio.Data.Crypto import Network.Minio.Sign.V4 -import Network.Minio.XmlParser -- runRequestDebug r mgr = do -- print $ "runRequestDebug" @@ -94,17 +93,3 @@ requestInfo :: Method -> Maybe Bucket -> Maybe Object -> Query -> [Header] -> Payload -> RequestInfo requestInfo m b o q h p = RequestInfo m b o q h p "" - -getService :: Minio [BucketInfo] -getService = do - resp <- executeRequest $ - requestInfo HT.methodGet Nothing Nothing [] [] $ - PayloadSingle "" - parseListBuckets $ NC.responseBody resp - -getLocation :: Bucket -> Minio Text -getLocation bucket = do - resp <- executeRequest $ - requestInfo HT.methodGet (Just bucket) Nothing [("location", Nothing)] [] - (PayloadSingle "") - parseLocation $ NC.responseBody resp diff --git a/src/Network/Minio/S3API.hs b/src/Network/Minio/S3API.hs new file mode 100644 index 0000000..456e8f8 --- /dev/null +++ b/src/Network/Minio/S3API.hs @@ -0,0 +1,30 @@ +module Network.Minio.S3API + ( getService + , getLocation + ) where + +import qualified Network.HTTP.Types as HT +import qualified Network.HTTP.Conduit as NC + + +import Lib.Prelude + +import Network.Minio.Data +import Network.Minio.API +import Network.Minio.XmlParser + +getService :: Minio [BucketInfo] +getService = do + resp <- executeRequest $ + requestInfo HT.methodGet Nothing Nothing [] [] $ + PayloadSingle "" + parseListBuckets $ NC.responseBody resp + +getLocation :: Bucket -> Minio Text +getLocation bucket = do + resp <- executeRequest $ + requestInfo HT.methodGet (Just bucket) Nothing [("location", Nothing)] [] + (PayloadSingle "") + parseLocation $ NC.responseBody resp + +-- getObject ::