Use tlsManagerSettings if connectIsSecure is True

Also provide convenient default instances for ConnectInfo for AWS and
play (minio service).
This commit is contained in:
Krishnan Parthasarathi 2017-02-08 11:22:32 +05:30 committed by Aditya Manthramurthy
parent b36fbb3a2f
commit d17d6f216d
2 changed files with 27 additions and 1 deletions

View File

@ -2,6 +2,8 @@ module Network.Minio
(
ConnectInfo(..)
, aws
, play
, connect
, Minio

View File

@ -28,6 +28,28 @@ data ConnectInfo = ConnectInfo {
instance Default ConnectInfo where
def = ConnectInfo "localhost" 9000 "minio" "minio123" False
-- |
-- Default aws ConnectInfo. Credentials should be supplied before use.
aws :: ConnectInfo
aws = def {
connectHost = "s3.amazonaws.com"
, connectPort = 443
, connectAccessKey = ""
, connectSecretKey = ""
, connectIsSecure = True
}
-- |
-- Default minio play server ConnectInfo. Credentials are already filled.
play :: ConnectInfo
play = def {
connectHost = "play.minio.io"
, connectPort = 9000
, connectAccessKey = "Q3AM3UQ867SPQQA43P2F"
, connectSecretKey = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
, connectIsSecure = True
}
-- |
-- Represents a bucket in the object store
type Bucket = Text
@ -180,7 +202,9 @@ data MinioConn = MinioConn {
-- be passed to 'runMinio'
connect :: ConnectInfo -> IO MinioConn
connect ci = do
mgr <- NC.newManager defaultManagerSettings
let settings = bool defaultManagerSettings NC.tlsManagerSettings $
connectIsSecure ci
mgr <- NC.newManager settings
return $ MinioConn ci mgr
-- | Run the Minio action and return the result or an error.