Fork me on GitHub
#pedestal
<
2017-09-19
>
cap10morgan01:09:46

Is there a way to plug a pedestal service (routes and all) into lein-figwheel's ring-handler?

mtnygard12:09:01

@cap10morgan I'm not sure what that means. I've used lein-figwheel, but just for serving up the CLJS app. I normally run the back end (with Pedestal) in a separate process.

cap10morgan14:09:33

@mtnygard Yeah, that's what I'm trying to avoid (the separate process). lein-figwheel has a :ring-handler value you can set in project.clj, but I'd love to have it go through my pedestal routes, etc. rather than having to plug it into the ring-handler-esque guts of an interceptor (i.e. just the fn of a request that returns a response). My goal is to keep things simple for my team. The more I can give them one command to run (ideally the one that everyone else's examples online also run) to spin up their dev environments, the better. So if lein figwheel could be made to interact with the pedestal service w/o needing to run a separate command, that would be great (even if it's not via :ring-handler).

ddeaguiar14:09:24

That may be useful to you

cap10morgan14:09:29

@ddeaguiar thanks I'll check it out

cap10morgan14:09:00

The message I'm getting is that neither pedestal nor (lein-)figwheel are going to help me do this. 🙂 This is a helpful starting point for achieving a similar goal though, so thanks.

john19:09:59

I'm using ring-redis-session (https://github.com/clojusc/ring-redis-session) with pedestal and the :session/keyof the request parameter does not appear to be accessible anywhere (that I can find) until a second request comes through. Has anyone experienced anything like that?

mtnygard19:09:57

@john That sounds very strange. How is the client sending that parameter?

john19:09:40

@mtnygard I thought the ring-redis-session middleware was attaching the session key to :session/key in :request on the server side.

mtnygard19:09:05

Hmm. OK, let me look at the source for that library for a second.

john19:09:36

Thanks! One more strange aspect: the :session/key always remains nil unless I add some content to :request :session in some interceptor

mtnygard19:09:01

In bare-session-request, it only attaches the :session/key if an existing session was found.

john19:09:07

It could be that the initial request is required so that my dummy data in the :session key gets placed. Then the second request succeeds. However, if I try to put data in the :session key very early in the interceptor chain, that does not suffice.

mtnygard19:09:09

So on the first request, there isn’t a session yet

mtnygard19:09:37

Your handler can return a response with a session, at which point ring-session will send that cookie down. The client returns it on the next request and bare-session-handler finds the existing session for you

mtnygard19:09:59

A caution: if you ever return a response with no session, then any existing session gets deleted!

john19:09:13

understood