ring-clojure / ring-codec

Utility library for encoding and decoding data
MIT License
63 stars 30 forks source link

Consider dropping commons-codec lib in favor of java.util.Base64 #26

Closed borkdude closed 1 year ago

borkdude commented 3 years ago

The java.util.Base64 class comes with Java 8. Java 7 is no longer publicly supported. I think it would be safe to replace the commons-codec dependency with pure Java: this library only uses it for base64 encoding/decoding.

This has an additional benefit: this library will become compatible with babashka:

(require '[babashka.deps :as deps]
         '[org.httpkit.server :as server])

(deps/add-deps '{:deps {ring/ring {:mvn/version "1.9.0"}
                        ring/ring-codec {:git/url "https://github.com/borkdude/ring-codec"
                                         :sha "5142b1334e1a8a2e5b1a88759b0746c77e33a0b8"
                                         :deps/manifest :deps}}})

(require '[ring.middleware.params :as p])

(server/run-server (p/wrap-params
                    (fn [req]
                      {:body (:query-params req)}))
                   {:port 8090})

@(promise)
http://localhost:8090/?q=1&q=2
;; =>
["q" ["1" "2"]]

I have already applied this change at a fork here: https://github.com/borkdude/ring-codec and all the tests are passing.

Let me know if you want to receive a PR.

weavejester commented 3 years ago

This seems reasonable. I'd happily accept a PR.

devurandom commented 1 year ago

https://github.com/ring-clojure/ring-codec/pull/27 is merged. Should this issue be closed?

borkdude commented 1 year ago

Thanks for pinging me @devurandom