This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-02
Channels
- # beginners (29)
- # cider (41)
- # clara (1)
- # cljs-dev (17)
- # cljsrn (1)
- # clojure (158)
- # clojure-dev (2)
- # clojure-dusseldorf (2)
- # clojure-italy (8)
- # clojure-mexico (1)
- # clojure-russia (2)
- # clojure-spec (43)
- # clojure-uk (1)
- # clojurescript (44)
- # community-development (98)
- # cursive (9)
- # data-science (8)
- # datascript (4)
- # datomic (30)
- # emacs (6)
- # fulcro (11)
- # graphql (6)
- # jobs (1)
- # jobs-discuss (27)
- # lein-figwheel (5)
- # luminus (13)
- # lumo (4)
- # off-topic (28)
- # onyx (9)
- # parinfer (12)
- # perun (2)
- # portkey (5)
- # re-frame (48)
- # ring (2)
- # shadow-cljs (52)
- # spacemacs (29)
- # tools-deps (15)
- # unrepl (9)
- # vim (7)
- # yada (3)
For information @cgrand, this fn
work with aws examples
(defn req-text->req-map-revisited [req]
(let [[_ request-method full-uri protocol headers+body] (re-find #"(?s)([A-Z]+)\s(.+)\s(HTTP/1\.1)\n(.*)" req)
headers (for [[_ header value] (re-seq #"(?s)(\S+):(.*?\n(?:[\t ].*?\n)*)" (str headers+body "\n"))]
[header (s/trim-newline value)])
body (re-find #"Param1=value1" headers+body)
[_ uri query-string] (re-find #"(?s)([\S&&[^?]]+)\??(\S+)?" full-uri)]
(cond->
{:request-method request-method
:uri full-uri
:protocol protocol}
(not (or (empty? headers) (nil? headers))) (assoc :headers
(into {}
(x/by-key (comp (interpose ",")
x/str))
headers))
(not (nil? body)) (assoc :body body)
(not (nil? query-string)) (assoc :query-string query-string :uri uri)
true (as->
req-map
(assoc req-map :server-name (get-in req-map [:headers "Host"]))
(update req-map :headers dissoc "Host")))))
I am not the best at regex but at least it does format the way sigv4
needs request
now I am going to try to make tests pass 😄