我可以在本地成功使用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
后我没有收到任何错误或记录。该功能似乎停止并且永不停止。
有什么想法吗?