Skip to content

Commit

Permalink
Fix bytes response
Browse files Browse the repository at this point in the history
  • Loading branch information
FieryCod committed Jul 12, 2021
1 parent 75bd870 commit 96b8902
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 62 deletions.
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{:deps {org.clojure/clojure {:mvn/version "1.10.3"}
metosin/jsonista {:mvn/version "0.3.3"}
io.github.FieryCod/holy-lambda-default-retriever {:mvn/version "0.0.6"}
io.github.FieryCod/holy-lambda-default-retriever {:mvn/version "0.0.7-SNAPSHOT"}
com.amazonaws/aws-lambda-java-core {:mvn/version "1.2.1"}}
:paths ["src"]}
9 changes: 2 additions & 7 deletions modules/holy-lambda-async-retriever/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>io.github.FieryCod</groupId>
<artifactId>holy-lambda-async-retriever</artifactId>
<packaging>jar</packaging>
<version>0.0.6</version>
<version>0.0.7-SNAPSHOT</version>
<name>holy-lambda-async-retriever</name>
<description>Support for async handlers which returns channel as a response.</description>
<url>https://github.com/FieryCod/holy-lambda/tree/master/modules/holy-lambda-async-retriever</url>
Expand All @@ -14,12 +14,7 @@
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>
<scm>
<url>https://github.com/FieryCod/holy-lambda</url>
<connection>scm:git:git://github.com/FieryCod/holy-lambda.git</connection>
<developerConnection>scm:git:ssh://git@github.com/FieryCod/holy-lambda.git</developerConnection>
<tag>8747d72e4c1a8d7a842d4da392a8d95f9d15b453</tag>
</scm>
<scm/>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
Expand Down
2 changes: 1 addition & 1 deletion modules/holy-lambda-async-retriever/project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject io.github.FieryCod/holy-lambda-async-retriever "0.0.6"
(defproject io.github.FieryCod/holy-lambda-async-retriever "0.0.7-SNAPSHOT"
:description "Support for async handlers which returns channel as a response."

:url "https://github.com/FieryCod/holy-lambda/tree/master/modules/holy-lambda-async-retriever"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
(defn <-wait-for-response
[response]
(cond
(or (map? response)
(nil? response)
(string? response))
(or
(bytes? response)
(map? response)
(nil? response)
(string? response))
response

(chan? response)
Expand Down
2 changes: 1 addition & 1 deletion modules/holy-lambda-babashka-layer/deps.edn
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{:deps {io.github.FieryCod/holy-lambda {:mvn/version "0.2.2"}
{:deps {io.github.FieryCod/holy-lambda {:mvn/version "0.2.3-SNAPSHOT"}
io.github.FieryCod/holy-lambda-babashka-shim {:mvn/version "0.2.1"}}}
2 changes: 2 additions & 0 deletions modules/holy-lambda-babashka-tasks/.dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((nil
(cider-clojure-cli-global-options . "-A:holy-lambda-local")))
8 changes: 5 additions & 3 deletions modules/holy-lambda-babashka-tasks/src/example/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[fierycod.holy-lambda.interceptor :as i]
[fierycod.holy-lambda.agent :as agent]
[clojure.string :as str]
[fierycod.holy-lambda.util :as u]
[fierycod.holy-lambda.native-runtime :as native]
[fierycod.holy-lambda.response :as hr]
[fierycod.holy-lambda.core :as h]))
Expand All @@ -14,12 +15,13 @@
(println "Log incomming request:" request)
request)})


(h/deflambda ExampleLambda <
{:interceptors [LogIncommingRequest]}
[request]
#?(:bb
(hr/text (str "Babashka is sweet friend of mine! Babashka version: " (System/getProperty "babashka.version")))
:clj (hr/text "Why you didn't use babashka? ;/")))
(hr/png-image "iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAclBMVEX///9YgdhNetZQfNdTftdVf9dKeNbz9vz7/P75+/5HdtXu8vtehtpZgtlchNnq7/rg5/d1lt7T3fRqjtyLpuOzxOx+nOBwkt1jidqetOf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ypoint [#'ExampleLambda])

Expand Down
9 changes: 2 additions & 7 deletions modules/holy-lambda-default-retriever/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>io.github.FieryCod</groupId>
<artifactId>holy-lambda-default-retriever</artifactId>
<packaging>jar</packaging>
<version>0.0.6</version>
<version>0.0.7-SNAPSHOT</version>
<name>holy-lambda-default-retriever</name>
<description>Default retriever for payloads</description>
<url>https://github.com/FieryCod/holy-lambda/tree/master/modules/holy-lambda-default-retriever</url>
Expand All @@ -14,12 +14,7 @@
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>
<scm>
<url>https://github.com/FieryCod/holy-lambda</url>
<connection>scm:git:git://github.com/FieryCod/holy-lambda.git</connection>
<developerConnection>scm:git:ssh://git@github.com/FieryCod/holy-lambda.git</developerConnection>
<tag>8747d72e4c1a8d7a842d4da392a8d95f9d15b453</tag>
</scm>
<scm/>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
Expand Down
2 changes: 1 addition & 1 deletion modules/holy-lambda-default-retriever/project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject io.github.FieryCod/holy-lambda-default-retriever "0.0.6"
(defproject io.github.FieryCod/holy-lambda-default-retriever "0.0.7-SNAPSHOT"
:description "Default retriever for payloads"

:url "https://github.com/FieryCod/holy-lambda/tree/master/modules/holy-lambda-default-retriever"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
(defn <-wait-for-response
[response]
(cond
(or (map? response)
(nil? response)
(string? response))
(or
(bytes? response)
(map? response)
(nil? response)
(string? response))
response

;; Potentially a promise or future
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>io.github.FieryCod</groupId>
<artifactId>holy-lambda</artifactId>
<packaging>jar</packaging>
<version>0.2.2</version>
<version>0.2.3-SNAPSHOT</version>
<name>holy-lambda</name>
<description>Micro framework which turns your code into AWS Lambda functions</description>
<url>https://github.com/FieryCod/holy-lambda</url>
Expand All @@ -18,7 +18,7 @@
<url>https://github.com/FieryCod/holy-lambda</url>
<connection>scm:git:git://github.com/FieryCod/holy-lambda.git</connection>
<developerConnection>scm:git:ssh://git@github.com/FieryCod/holy-lambda.git</developerConnection>
<tag>c34246fc735a20e6c8f868df7d8e91b1bd696745</tag>
<tag>d6a393078fead78346d565b0835e0e5a3b27c77c</tag>
</scm>
<build>
<sourceDirectory>src</sourceDirectory>
Expand Down Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>io.github.FieryCod</groupId>
<artifactId>holy-lambda-default-retriever</artifactId>
<version>0.0.6</version>
<version>0.0.7-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Expand Down
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject io.github.FieryCod/holy-lambda "0.2.2"
(defproject io.github.FieryCod/holy-lambda "0.2.3-SNAPSHOT"
:description "Micro framework which turns your code into AWS Lambda functions"

:url "https://github.com/FieryCod/holy-lambda"
Expand All @@ -13,7 +13,7 @@
:dependencies [[org.clojure/clojure "1.10.3" :scope "provided"]
[metosin/jsonista "0.3.3"]
[com.amazonaws/aws-lambda-java-core "1.2.1"]
[io.github.FieryCod/holy-lambda-default-retriever "0.0.6"]]
[io.github.FieryCod/holy-lambda-default-retriever "0.0.7-SNAPSHOT"]]

:eftest {:thread-count 4}

Expand Down
36 changes: 13 additions & 23 deletions src/fierycod/holy_lambda/interceptor.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
(throw (Exception. (str "Entry " ~?type " for interceptor \"" ~?sym "\" should be a function.")))
(fn [payload#]
(try
(update-in (retriever/<-wait-for-response (~?handler payload#))
[::interceptors :complete ~?type]
(fnil conj [])
~?sym)
(let [response# (retriever/<-wait-for-response (~?handler payload#))]
(if-not (map? response#)
response#
(update-in response#
[::interceptors :complete ~?type]
(fnil conj [])
~?sym)))
(catch Exception ex#
(update-in payload#
[::interceptors :ex]
Expand Down Expand Up @@ -65,7 +68,7 @@
:leave ~wrapped-leave}]
`(def ~?sym ~?docstring ~interceptor)))))

#?(:bb
#?(:clj
(defn- process-interceptors
[mixin payload type]
(if-let [interceptors (seq (:interceptors mixin))]
Expand All @@ -75,9 +78,12 @@
result payload]
(if-not (seq interceptors)
result
(recur (rest interceptors) (if-let [interceptor (type (first interceptors))] (interceptor result) result))))
(recur (rest interceptors)
(if-let [interceptor (type (first interceptors))]
(interceptor result)
result))))
payload))
:cljs
:default
(defn- process-interceptors
[mixin payload type]
(if-let [interceptors (seq (:interceptors mixin))]
Expand All @@ -88,20 +94,4 @@
(if-not (seq interceptors)
result
(recur (rest interceptors) (if-let [interceptor (type (first interceptors))] (interceptor result) result))))
payload))
:clj
(defn- process-interceptors
[mixin payload type]
(if-let [interceptors (seq (:interceptors mixin))]
(let [it (some-> (if (= type :leave)
(reverse interceptors)
interceptors)
clojure.lang.RT/iter)]
(loop [result payload]
(if (.hasNext it)
(recur
(if-let [interceptor (some-> (.next it) type)]
(interceptor result)
result))
result)))
payload)))
8 changes: 8 additions & 0 deletions src/fierycod/holy_lambda/response.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns fierycod.holy-lambda.response
"Response helpers adapted from ring-core/util/response.clj"
(:require
[fierycod.holy-lambda.util :as u]
[clojure.string :as s]))

(def redirect-status-codes
Expand All @@ -20,6 +21,13 @@
:headers {"location" url}
:body nil}))

(defn png-image
[base64-str]
{:isBase64Encoded true
:body base64-str
:statusCode 200
:headers {"content-type" "image/png"}})

(defn created
"Returns a response for a HTTP 201 created response."
{:added "1.2"}
Expand Down
23 changes: 16 additions & 7 deletions src/fierycod/holy_lambda/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,36 @@
(defn response->bytes
[?response]
(let [response (retriever/<-wait-for-response ?response)
bytes-response? #?(:clj (bytes? response)
:default false)
;; remove internals
response (dissoc response :fierycod.holy-lambda.interceptor/interceptors)
ctype (content-type response)]
response (if-not bytes-response?
(dissoc response :fierycod.holy-lambda.interceptor/interceptors)
response)
ctype (when-not bytes-response?
(content-type response))]

(cond
bytes-response?
response

;; Optimize the common case
(json-content-type? ctype)
(x->json-bytes (update response :body x->json-string))

;; Ack event
(nil? response)
(x->json-bytes {:body nil
:statusCode 200})

(contains? #{"text/plain"
"text/plain; charset=utf-8"
"image/png"
"text/html"
"text/html; charset=utf-8"}
ctype)
(x->json-bytes response)

;; Ack event
(nil? response)
(x->json-bytes {:body nil
:statusCode 200})

;; Handle redirect. Redirect should have nil? body
(and (get-in response [:headers "location"])
(nil? (:body response)))
Expand Down

0 comments on commit 96b8902

Please sign in to comment.