Safe Haskell | None |
---|---|
Language | Haskell2010 |
Handle uploading to a hackage server, using the HTTP
API described
in the
Hackage server documentation.
- type HResponse = Response
- data Auth = Auth {}
- data Options = Options (Request -> Request)
- defaultOptions :: Maybe Auth -> Options
- mkAuth :: String -> String -> Maybe Auth
- getUploadUrl :: String -> Upload -> String
- buildRequest :: String -> Upload -> Maybe Auth -> IO Request
- sendRequest :: Request -> IO (Either HttpException Response)
- data Response = Response {}
- postPkg :: String -> FilePath -> Maybe ByteString -> Maybe Auth -> IO Request
- putDocs :: String -> FilePath -> Maybe ByteString -> Maybe Auth -> IO Request
- mkPart :: FilePath -> ByteString -> Part
- bodyToByteString :: RequestBody -> ByteString
- module Distribution.Hup.Types
- data Auth = Auth {}
Documentation
Username and password for HTTP basic access authentication.
Options that can be applied to a Request. (e.g. to add standard headers, etc.)
Can just use defaultOptions
.
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)
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
).
module Distribution.Hup.Types