This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-31
Channels
- # aws (2)
- # beginners (101)
- # cider (8)
- # clara (8)
- # cljs-dev (3)
- # cljsrn (17)
- # clojars (2)
- # clojure (67)
- # clojure-austin (2)
- # clojure-finland (1)
- # clojure-france (5)
- # clojure-italy (3)
- # clojure-nl (3)
- # clojure-russia (2)
- # clojure-serbia (1)
- # clojure-spec (72)
- # clojure-uk (112)
- # clojurescript (92)
- # core-async (74)
- # core-typed (2)
- # cursive (8)
- # datomic (2)
- # duct (5)
- # emacs (35)
- # events (11)
- # fulcro (32)
- # instaparse (9)
- # jobs (1)
- # luminus (1)
- # lumo (3)
- # off-topic (118)
- # om (2)
- # onyx (10)
- # pedestal (5)
- # re-frame (21)
- # reagent (48)
- # reitit (40)
- # ring (12)
- # shadow-cljs (113)
- # spacemacs (21)
- # tools-deps (47)
muuntaja presented some problems with how it formats the body (ByteArrayInputStream), and aws’ expected format
but the gist of it was:
(ns slack-api.lambda
(:require [ :as io]
[duct.core :as duct]
[integrant.core :as ig]
[clojure.data.json :as json]
[uswitch.lambada.core :refer [deflambdafn]]))
(duct/load-hierarchy)
(let [config (-> (duct/read-config (io/resource "slack_api/config.edn"))
duct/prep)
handler (-> config
(ig/init [:duct.core/handler])
:duct.core/handler)]
(deflambdafn slack-api.lambda.LambdaFn [is os ctx]
(with-open [writer (io/writer os)]
(let [request (json/read (io/reader is :encoding "UTF-8") :key-fn keyword)
response (handler request)]
(-> response
:body
slurp
(as-> body (assoc response :body body))
(assoc :isBase64Encoded false)
(select-keys [:body :statusCode :headers :isBase64Encoded])
(json/write writer))))))