Safe Haskell | None |
---|---|
Language | Haskell2010 |
Handle uploading to a hackage server, using the HTTP
API described
in the
Hackage server documentation.
- type WResponse = Response
- data Upload = Upload {}
- defaultOptions :: Maybe Auth -> Options
- mkAuth :: String -> String -> Maybe Auth
- getUploadUrl :: String -> Upload -> String
- upload :: String -> Upload -> Maybe Auth -> IO (WResponse ByteString)
- data Response = Response {}
- mkResponse :: WResponse ByteString -> Response
- postPkg :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString)
- putDocs :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString)
- testUpload :: IO (WResponse ByteString)
- module Distribution.Hup.Types
- data Auth :: *
Documentation
Bundle together information useful for an upload.
Upload | |
|
defaultOptions :: Maybe Auth -> Options Source #
returns default options to use with a request.
We try to request plain text where possible; and we allow non-success statuses to still return normally (rather than throwing an exception)
mkAuth :: String -> String -> Maybe Auth Source #
pack a name and password into an Auth
structure
>>>
mkAuth "myname" "mypassword"
getUploadUrl :: String -> Upload -> String Source #
work out what URL to upload a .tgz file to.
getUploadUrl server upload
returns a URL.
>>>
getUploadUrl "http://localhost:8080/" $ Upload (Package "foo" "0.1.0.0") "./hup-0.1.0.0.tar.gz" IsDocumentation CandidatePkg
"http://localhost:8080/package/foo-0.1.0.0/candidate/docs"
upload :: String -> Upload -> Maybe Auth -> IO (WResponse ByteString) Source #
upload serverUrl upl userAuth
- upload some package (details
packed into upl
to the server at serverUrl
, using
the credentials in userAuth
.
Relevant bits of server response, packed into a record
for those who don't want to deal with wreq's
Response
type.
mkResponse :: WResponse ByteString -> Response Source #
postPkg :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString) Source #
Do a POST
request to upload a package.
postPkg url fileName userAuth
will try to upload the file given
by fileName
to the URL at url
, using the user authentication
userAuth
.
putDocs :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString) Source #
Do a PUT
request to upload package documentation.
postPkg url fileName userAuth
will try to upload the file given
by fileName
to the URL at url
, using the user authentication
userAuth
.
testUpload :: IO (WResponse ByteString) Source #
module Distribution.Hup.Types
Supported authentication types.
Do not use HTTP authentication unless you are using TLS encryption. These authentication tokens can easily be captured and reused by an attacker if transmitted in the clear.
BasicAuth ByteString ByteString | Basic authentication. This consists of a plain username and password. |
OAuth2Bearer ByteString | An OAuth2 bearer token. This is treated by many services as the equivalent of a username and password. |
OAuth2Token ByteString | A not-quite-standard OAuth2 bearer token (that seems to be used only by GitHub). This is treated by whoever accepts it as the equivalent of a username and password. |
AWSAuth AWSAuthVersion ByteString ByteString | Amazon Web Services request signing AWSAuthVersion key secret |
OAuth1 ByteString ByteString ByteString ByteString | OAuth1 request signing OAuth1 consumerToken consumerSecret token secret |