diff --git a/README.adoc b/README.adoc index 51e1d6d..314613c 100644 --- a/README.adoc +++ b/README.adoc @@ -55,19 +55,20 @@ my-function: In `bb` language: [source, clojure] ---- -(defn handler [{:keys [headers body context] :as event}] ...) +(defn handler [{:keys [headers body context] :as event}] + ...) ---- -The `event` is a map containing the request `:headers`, `:body` and `:context` keys. +`event` is a map containing `:headers`, `:body` and `:context` keys. -`context` contains a map of environment variables. - -The `:headers` key contains headers, as such: +`:headers` contains headers, as such: [source, clojure] ---- {:content-type "application/json"} ---- -The `:env` map contains a map with the environment variables. Additional environment variables can be defined in the `stack.yml` file, as such: +`:body` is the payload body. + +`:context` contains environment variables. Additional environment variables can be defined in the `stack.yml` file, as such: [source, yml] ---- my-function: @@ -78,14 +79,14 @@ my-function: MY_ENV1: foo MY_ENV2: 2 ---- -The `:env` key will contain: +`:context` will contain: [source, clojure] ---- {:my-env1 "foo" :my-env2 2} ---- -There are cases where string keys are preferable in the payload body, and it's possible to support them by setting `keywords: false` in the Function in `stack.yml`: +There are cases where it's preferable to have string keys in the payload body, and it's possible to support them by setting `keywords: false` in the Function in `stack.yml`: [source, yml] ---- my-function: diff --git a/template/bb/Dockerfile b/template/bb/Dockerfile index 1b42ccb..b3db5c2 100644 --- a/template/bb/Dockerfile +++ b/template/bb/Dockerfile @@ -19,7 +19,7 @@ USER app WORKDIR $HOME COPY index.clj function/bb.edn ./ -COPY ring ./ring +COPY lib ./lib COPY function function RUN bb prepare && bb print-deps diff --git a/template/bb/lib/ring/util/response.clj b/template/bb/lib/ring/util/response.clj index ed4f0a5..463646f 100644 --- a/template/bb/lib/ring/util/response.clj +++ b/template/bb/lib/ring/util/response.clj @@ -87,7 +87,7 @@ (defn- canonical-path ^String [^File file] (str (.getCanonicalPath file) - (if (.isDirectory file) File/separatorChar))) + (when (.isDirectory file) File/separatorChar))) (defn- safe-path? [^String root ^String path] (.startsWith (canonical-path (File. root path)) @@ -173,7 +173,7 @@ ;; As a work-around, we'll backport the fix from CLJ-1177 into ;; url-as-file. -(defn- ^File url-as-file [^java.net.URL u] +(defn- url-as-file ^File [^java.net.URL u] (-> (.getFile u) (str/replace \/ File/separatorChar) (str/replace "+" (URLEncoder/encode "+" "UTF-8"))