diff options
author | Eduardo Julian | 2020-11-07 00:29:40 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-11-07 00:29:40 -0400 |
commit | 2e5852abb1ac0ae5abdd8709238aca447f62520e (patch) | |
tree | 1b73a24205217c9e00f7f17d5972f67735a7cc69 /stdlib/source/program/aedifex/upload.lux | |
parent | ef78c1f92ab29c4370193591b170535dd9e743f7 (diff) |
Pure-Lux implementation for biggest and smallest Frac values.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/program/aedifex/upload.lux | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/stdlib/source/program/aedifex/upload.lux b/stdlib/source/program/aedifex/upload.lux deleted file mode 100644 index 391413f03..000000000 --- a/stdlib/source/program/aedifex/upload.lux +++ /dev/null @@ -1,95 +0,0 @@ -(.module: - [lux #* - ["." host (#+ import:)] - [abstract - [monad (#+ Monad do)]] - [control - ["." io (#+ IO)] - ["." try (#+ Try)] - ["." exception (#+ exception:)]] - [data - ["." binary (#+ Binary)] - ["." text - ["%" format (#+ format)] - ["." encoding]]] - [time - ["." instant]] - [world - [net (#+ URL) - ["." uri]]]] - ["." // #_ - ["#." repository (#+ Address User Password)] - ["#." dependency (#+ Dependency)] - ["#." artifact]]) - -(type: #export (Action a) - (IO (Try a))) - -(def: #export monad - (:coerce (Monad Action) - (try.with io.monad))) - -(def: (url repository dependency) - (-> Address Dependency URL) - (format repository - uri.separator - (//artifact.uri (get@ #//dependency.artifact dependency)) - "." - (get@ #//dependency.type dependency))) - -(import: java/lang/AutoCloseable - (close [] #io #try void)) - -(import: java/io/OutputStream - (flush [] #io #try void) - (write [[byte]] #io #try void)) - -(import: java/lang/String) - -(import: java/net/URLConnection - (setDoOutput [boolean] #io #try void) - (setRequestProperty [java/lang/String java/lang/String] #io #try void) - (getOutputStream [] #io #try java/io/OutputStream)) - -(import: java/net/HttpURLConnection - (setRequestMethod [java/lang/String] #io #try void) - (getResponseCode [] #io #try int)) - -(import: java/net/URL - (new [java/lang/String]) - (openConnection [] #io #try java/net/URLConnection)) - -(import: java/util/Base64$Encoder - (encodeToString [[byte]] java/lang/String)) - -(import: java/util/Base64 - (#static getEncoder [] java/util/Base64$Encoder)) - -(exception: #export (failure {code Int}) - (exception.report - ["Code" (%.int code)])) - -(def: (basic-auth user password) - (-> User Password Text) - (format "Basic " (java/util/Base64$Encoder::encodeToString (encoding.to-utf8 (format user ":" password)) - (java/util/Base64::getEncoder)))) - -(def: #export (upload repository user password dependency content) - (-> Address User Password Dependency Binary - (Action Any)) - (do {! ..monad} - [connection (|> (..url repository dependency) - java/net/URL::new - java/net/URL::openConnection) - #let [connection (:coerce java/net/HttpURLConnection connection)] - _ (java/net/HttpURLConnection::setRequestMethod "PUT" connection) - _ (java/net/URLConnection::setDoOutput true connection) - _ (java/net/URLConnection::setRequestProperty "Authorization" (..basic-auth user password) connection) - stream (java/net/URLConnection::getOutputStream connection) - _ (java/io/OutputStream::write content stream) - _ (java/io/OutputStream::flush stream) - _ (java/lang/AutoCloseable::close stream) - code (java/net/HttpURLConnection::getResponseCode connection)] - (case code - +200 (wrap []) - _ (:: io.monad wrap (exception.throw ..failure [code]))))) |