Fork me on GitHub
#holy-lambda
<
2021-11-03
>
Karol Wójcik08:11:23

Idea Now holy-lambda-adapter supports ring style handlers, so that you can use Ring with HL.

(defn ring-handler
  [request]
  {:status 200
   :headers {}
   :body \"Hello World\"}

(def HttpApiProxyGateway (hlra/wrap-hl-req-res-model ring-handler))

(h/entrypoint [#'HttpApiProxyGateway])
I'm wondering whether adapter should support also a reversed conversion for development. Something like allowing HL handlers run on ring server.
(defn hl-style-handler
  [request]
  {:statusCode 200
   :headers {}
   :body {:something "something"}

(jetty/run-server (hlra/adapt-to-ring hl-style-handler) {})

Karol Wójcik08:11:23

@U0510KXTU I expect your input here since you already were doing something like this for yourself. Would you use the official library if that would be possible? 🙏

steveb8n08:11:15

tbh I’m a Pedestal user so I won’t use the Ring adapter

Karol Wójcik08:11:31

Isn't pedestal somewhat compatible with Ring?

steveb8n08:11:47

but for a local server I would consider it

Karol Wójcik08:11:14

Actually having an adapter for Pedestal would be cool

steveb8n08:11:21

yes Pedestal can adapt ring middlewares but the request/context shape is different

steveb8n08:11:51

I agree. Pedestal variant would be coo;

Karol Wójcik08:11:11

Do you have experience in shaping correct request for pedestal?

steveb8n08:11:35

it’s pretty simple. it’s just a context map with a :request key

Karol Wójcik08:11:02

Wondering how much would have to change 😄

Karol Wójcik08:11:01

Then we would have to reverse the conversion for local server as well, but yeah. I think it's doable

steveb8n08:11:17

you might be able to just use this lib io.pedestal/pedestal.interceptor

steveb8n08:11:37

without needing the full pedestal stack.

steveb8n08:11:17

although Pedestal with Jetty makes it pretty simple

Karol Wójcik08:11:37

Yeah. That would be cool. I would not have to implement interceptors (which are quite hard to implement if you want to be compatible with babashka) 😄