Clojurians
#pedestal
<
2017-01-13
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

mtnygard01:01:35

@curtosis Depending on when you last used it, the big story is probably breaking out some parts so they could be used independently of the web framework. E.g., interceptors can now be used in any Clojure application. Pedestal has also grown logging and metrics in recent times. Oh, and 0.5.2 was released today.

mtnygard01:01:36

@rafaelzlisboa: I don't think io.pedestal.test offers anything for SSE

martinklepsch13:01:51

When using interceptors, would it be an anti-pattern to add stuff to the beginning of the queue by recreating it with existing items at the end?

martinklepsch13:01:12

I have a situation where I want to do thing A or thing B based on the resulting context from a previous interceptor basically

mavbozo13:01:47

@martinklepsch i don't understand your first sentence but I have made a authenticate-interceptor-->authorize-interceptor chain where I put user data in context inside authenticate-interceptor and the authorize interceptor do things differently based on the rule and user data put by the previous (authenticate) interceptor

curtosis13:01:53

@mtnygard thanks … I think I last played with it a few months after the app side went away. So it’s been a while. :slightly_smiling_face:

martinklepsch14:01:23

@mavbozo What you’re describing is Interceptor A influencing the behavior of interceptor B. What I’m trying to figure out is how the result of Interceptor A could influence wether interceptor B or interceptor C is used.

martinklepsch14:01:45

> When using interceptors, would it be an anti-pattern to add stuff to the beginning of the queue by recreating it with existing items at the end? Agreed that this probably wasn’t very clear. :slightly_smiling_face: The ::queue in the interceptor context is a FIFO queue which means I can’t add things to the beginning without recreating it completely (I think). Does that make it any clearer?

kirill.salykin14:01:08

as far as I know you can change interceptors queue, similar to what router currently doing

kirill.salykin14:01:30

routes is interceptor, which updates interceptor queue

martinklepsch14:01:12

You’re right about the router modifying the queue but it adds interceptors to the end of it not to the beginning

kirill.salykin14:01:44

oh, you want o insert interceptors BEFORE currect?

rafaelzlisboa14:01:46

@mtnygard thanks for replying! do you know what’s the most common way to test it, even if not using the mock requests from io.pedestal.test?

martinklepsch14:01:40

@kirill.salykin yes

martinklepsch14:01:12

I think would get it working so I’m mostly wondering if I’m setting myself up for failure with this kind of thing

kirill.salykin14:01:50

maybe you can always have these intercepters, but they will work only in case of some attr attached to context map? (I assume you want them triggered in :leave state)?

martinklepsch14:01:38

yes that would be a workaround but it reminds me a lot of GOTO :smile:

martinklepsch14:01:18

(I want them triggered in :enter but I don’t think that’s too important… not using them in the context of HTTP reqs)

kirill.salykin14:01:54

yes, workaround looks a little like GOTO

mavbozo15:01:37

there is a key :io.pedestal.impl.interceptor/stack inside context which is - A PersistentList of interceptors which still need to be executed during the 'leave' stage. So long as this value is not empty, the tail of the list will be removed and executed.`

mavbozo15:01:16

suppose your chain is A -> B -> C

mavbozo15:01:35

maybe inside B interceptor you could push the new interceptor X to i.p.i.i/stack so that the leave chain become for example A <- X <- B <- C

curtosis15:01:54

I’m curious where/why people are picking pedestal to build on these days. Sort of a meta “where does it fit in the current landscape” question.

mavbozo15:01:19

@curtosis I feel pedestal features makes my code easier for me to understand. routes as data makes specifying routes and generating url in html pages unified--I don't have to hard code url in html template.

mavbozo15:01:20

routes as data makes me easier to specify different interceptors for each part of the website inside one route data. for example: my web-app could have different interceptors inside /backoffice and /api path while the rest of the paths /* are for customer

mavbozo15:01:25

injecting dependencies become easier--just put the required components inside context instead of putting the required components inside :request or :response map. It feels cleaner

mavbozo15:01:46

just my personal feeling about pedestal. I never used modern framework such as Django, RoR, CodeIgniter seriously. Before using clojure, most of my time I maintained and developed non framework PHP web apps.

curtosis16:01:14

thanks, that’s a helpful way to look at it

curtosis16:01:21

my recent experimenting has been mostly in untangled, which is more of a om.next-centric story

curtosis16:01:45

(not to take anything away from untangled-server, of course; it’s just first and foremost conceived as a backend for the untangled om.next-based front-end)

curtosis16:01:31

I’m trying to get a better mental map of where pedestal sits today compared to, say hoplon or luminus (to pick two that come to mind)

dfcarpenter19:01:14

Hi everyone, beginner here. Im going through the beginning tutorials on the pedestal website (http://pedestal.io/guides/hello-world) and I have question about restarting the web server in a repl. The guide says I can just press Ctrl-C and it will kill the server which it does, but when I try to restart the server using (hello/start) it says the port is in use. Is there a different way to kill the server which releases the port so I can easily restart it?

mavbozo19:01:21

@dfcarpenter can you try again the steps but after you press Ctrl-C, please check whether the server is really killed by accessing the /greet url in the browser

ddeaguiar19:01:50

@dfcarpenter I typically bind the server to a var when starting. I then stop it using http/stop where http is an alias for io.pedestal.http.

dfcarpenter19:01:08

@mavbozo It looks like it isn’t. When I run the curl commands I get back a response.

ddeaguiar19:01:27

I assume your starting via run-dev found in the lein pedestal template?

ddeaguiar19:01:39

oh the guide, sec

dfcarpenter19:01:43

@ddeaguiar Ahh good idea. Ill try that. No i’m using the boot repl configuration in the tutorial

dfcarpenter19:01:58

In the next part of the guide it tells the reader to restart the server based on changes but it isn’t clear how to do that well. Maybe I should open an issue for it to be to clarified (like using a var for (hello/start)?

mavbozo19:01:03

you can still using the guide but add ::http/join? false in the http/create-server function

ddeaguiar19:01:03

@dfcarpenter the guide should be updated. If you don't bind the result of starting the server to a var then you can't stop it without killing the repl

mavbozo19:01:47

you can start the server by (def my-server (hello/start))

mavbozo19:01:28

then to stop the server use (io.pedestal.http/stop my-server)

ddeaguiar19:01:07

At the risk of being pedantic, I'd extend that to (alter-var-root #'my-server io.pedestal.http/stop)

dfcarpenter19:01:40

Thank you all for your help

ddeaguiar19:01:37

Thanks for the guide feedback. I'll look into issuing a pr with clarifications

ddeaguiar20:01:39

hmm, just saw Paul's response on the pedestal mailing list. I think I'm going to close this PR

dfcarpenter21:01:23

@ddeaguiar Thanks again! and yes I saw the thread.

ddeaguiar21:01:50

np, I left the PR open at Paul's discretion