aws-lambda

jsyrjala 2020-01-18T05:54:55.005800Z

If you use something other than InputStream/OutputStream as parameters to function, lambda will try to convert JSON to java classes.

jsyrjala 2020-01-18T05:55:42.006Z

https://github.com/jsyrjala/aws-lambda-serverless

jsyrjala 2020-01-18T05:57:46.007500Z

Most likely you’ll want to read input from a InputStream, and then parse it as JSON or END. If you go via lambda’s automatic JSON parsing, you’ll get java classes.

MatthewLisp 2020-01-18T14:09:54.008Z

Thanks @jsyrjala I’ll try it

MatthewLisp 2020-01-18T20:14:50.011100Z

@jsyrjala why in your template you state to AWS that you are receiving 2 parameters [InputStream OutputStream] And that you return void I thought I’d receive only one parameter, the InputStream and my output would be a OutputStream

jsyrjala 2020-01-18T20:41:15.013500Z

that is how JVM lambdas work if you want to parse request yourself

👍 1
dabrazhe 2020-01-18T20:41:39.013700Z

Hi. How can I quickly parse the input parameters in the handler function? It does not seem to a map I can destructure with keywords

(defn -handler
  [this input context] ... )

jsyrjala 2020-01-18T20:42:35.014200Z

parse input with e.g https://github.com/dakrone/cheshire

dabrazhe 2020-01-18T20:44:44.015600Z

thanks. when I print the input params it's {operation=echo, message=Hello world!} When I query its type it's java.util.LinkedHashMap. Doesn't look like json : )

jsyrjala 2020-01-18T20:49:07.017900Z

here built in jvm lambda framework has parsed incoming json to a Java LinkedHashMap object before calling your handler function.

jsyrjala 2020-01-18T20:50:59.019600Z

basically you can either use parameters [InputStream OutputStream] and handle JSON -> clojure datastructure parsing and clojure -> JSON response generation your self. Or use automatic conversion from JSON to Java classes and back to JSON. I have preferred the former.

dabrazhe 2020-01-18T20:55:34.021400Z

Interesting approach, thank you. I guess what I really need is clj version of js->clj :keywordize-keys true

jsyrjala 2020-01-18T20:57:39.021500Z

dabrazhe 2020-01-18T21:21:58.022200Z

Great, ty, will give it try