clj-http在本地工作但不在我的apex.run管理的Lambda函数中

时间:2017-12-16 16:05:27

标签: java apache lambda clojure aws-lambda

我可以在本地成功使用clj-http但在lambda中运行时我没有得到任何响应或错误消息。可疑功能如下。

(ns org.get_location.lambsay
    (:gen-class :implements [com.amazonaws.services.lambda.runtime.RequestStreamHandler])
    (:require [cheshire.core :as json]
            ;   [cheshire.core :refer [generate-string]] ; could probably include parse-stream here and get rid of above line
              [clojure.java.io :as io]
              [clojure.string :as str]
              [clj-http.client :as client]
              [org.httpkit.client :as http])
    (:import (com.amazonaws.services.lambda.runtime Context)))

(defn locations
    []
    (println "BBB")
    (:body (client/get "https://www.example.com/resource" {:as :json})))

(defn location
    [lat lng]
    (println "AAA")
    (println (locations))
    (println "CCC")
    (json/generate-string {:statusCode 200 :body (json/generate-string {:hi {:deeper "deepest!" :lat lat :lng lng}})}))

(defn -handleRequest
    [this input-stream output-stream context]
    (let [handle (io/writer output-stream)
          is (json/parse-stream (io/reader input-stream))
          query-string-parameters (get is "queryStringParameters")
          lat (bigdec (get query-string-parameters "lat"))
          lng (bigdec (get query-string-parameters "lng"))
          response (location lat lng)]
        (println response)
        (.write handle response)
        (.flush handle)))

我的主要困难是打印BBB后我没有收到任何错误或记录。该功能似乎停止并且永不停止。

有什么想法吗?

0 个答案:

没有答案