hup-0.3.0.0: Upload packages or documentation to a hackage server

Safe HaskellNone
LanguageHaskell2010

Distribution.Hup.Upload

Description

Handle uploading to a hackage server, using the HTTP API described in the Hackage server documentation.

Synopsis

Documentation

data Auth Source #

Username and password for HTTP basic access authentication.

Constructors

Auth 

Instances

Eq Auth Source # 

Methods

(==) :: Auth -> Auth -> Bool #

(/=) :: Auth -> Auth -> Bool #

Show Auth Source # 

Methods

showsPrec :: Int -> Auth -> ShowS #

show :: Auth -> String #

showList :: [Auth] -> ShowS #

data Options Source #

Options that can be applied to a Request. (e.g. to add standard headers, etc.)

Can just use defaultOptions.

Constructors

Options (Request -> Request) 

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"
Just (Auth {authUser = "myname", authPassword = "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") "./foo-0.1.0.0.tar.gz" Nothing IsDocumentation CandidatePkg
"http://localhost:8080/package/foo-0.1.0.0/candidate/docs"

buildRequest :: String -> Upload -> Maybe Auth -> IO Request Source #

buildRequest serverUrl upl userAuth - create an HTTP request for uploading some package (details packed into upl) to the server at serverUrl, using the credentials in userAuth.

e.g. usage:

let p = Package "foo" "0.1.0.0"
let u = Upload p "./foo-0.1.0.0.tar.gz" Nothing IsDocumentation CandidatePkg
req <- buildRequest "http://localhost:8080/" u (mkAuth "tmp" "tmp")
sendRequest req

sendRequest :: Request -> IO (Either HttpException Response) Source #

Send an HTTP request and get the response (or an exception)

data Response Source #

Relevant bits of server response, packed into a record for those who don't want to deal with http-clients's Response type.

See mkResponse.

postPkg :: String -> FilePath -> Maybe ByteString -> Maybe Auth -> IO Request Source #

Construct a POST request for uploading a package.

postPkg url conts userAuth creates a request which will upload the file conts in conts to the URL at url, using the user authentication userAuth.

putDocs :: String -> FilePath -> Maybe ByteString -> Maybe Auth -> IO Request Source #

Build a PUT request to upload package documentation.

putDocs url fileConts userAuth creates a request which will upload the file contents in fileConts to the URL at url, using the user authentication userAuth.

mkPart :: FilePath -> ByteString -> Part Source #

given a filename and contents, produce an http-client Part for uploading as a package to a hackage server

bodyToByteString :: RequestBody -> ByteString Source #

Convert a RequestBody to a ByteString.

For testing purposes. Won't work if your RequestBody is set up to do streaming (e.g. using the RequestBodyStream constructor/ partFileSource).

data Auth Source #

Username and password for HTTP basic access authentication.

Constructors

Auth 

Instances

Eq Auth Source # 

Methods

(==) :: Auth -> Auth -> Bool #

(/=) :: Auth -> Auth -> Bool #

Show Auth Source # 

Methods

showsPrec :: Int -> Auth -> ShowS #

show :: Auth -> String #

showList :: [Auth] -> ShowS #