Fork me on GitHub
#pedestal
<
2017-05-18
>
v3ga00:05:51

@nxqd absolutely, i’ve been tearing github apart looking for an example

v3ga00:05:41

@mtnygard thanks, that should do, i’ll take a look back at earlier posts as well. thanks

gerstree11:05:47

@mtnygard Thanks, so it's definitely worth diving into Vase to provide an API for an existing application?

mtnygard13:05:10

@gerstree I think so, but it will depend on how much logic is in your application. Vase is really meant to be a quick, easy way to shuttle data from HTTP into and out of Datomic. If you need more logic than Vase provides, you can use custom interceptors. The descriptor will start to get unwieldy when the chains are long.

mtnygard13:05:44

One thing I’ve done is use Vase to describe a bunch of the “dumb” routes that pump data back and forth, but then use hand-written routes to handle the more interesting cases.

mtnygard13:05:28

(I’ll post a gist with some bits that might come in handy for that)

jfntn16:05:36

I don’t have a logging setup in my project yet, if I want pedestal to print debug info I’ll have to configure logback with an xml file is that correct?

ddeaguiar16:05:04

apps generated through the lein templates will have a logback config

jfntn16:05:08

thanks, will take a look

jfntn16:05:41

Ah that worked, thanks @ddeaguiar

jfntn16:05:29

I guess I can’t ignore jvm logging libraries anymore :0

ddeaguiar16:05:09

Yeah. I little logback knowledge goes a long way 🙂

jfntn16:05:29

This is a sidetrack, but I’ve been logging everything as edn maps using pr-str for a while and it’s been really useful, are there any reasons why you would NOT want a custom logback appender to do that?

ddeaguiar16:05:59

I’ve not found a need to implement a custom appender thus far but I suppose it depends on the need

jfntn16:05:25

not familiar with that, does it parse the lines into data structures to make it easier to navigate them?

ddeaguiar16:05:05

well it at least pretty prints them

ddeaguiar16:05:12

you can expand/collapse lines

ddeaguiar16:05:19

and you can query your logs

jfntn17:05:42

Interesting, do you think you could do something like that before writing to the file or there would be too much overhead?

ddeaguiar18:05:06

@jfntn not sure I follow

jfntn18:05:52

Ha sorry missing some context here. In the previous rev of our backend we wrote a very simple logger that’d take a single clojure map and write it as edn. What was great about it was that consuming the logs was simple as something like (map edn/read-string (line-seq "app.log")) and then you can filter etc. What wasn’t so great was that our app logs were special snowflakes and we had to handle them separately from the logs printed by all our dependencies. I didn’t know of lnav but what I’m wondering now is could we apply the same kind of processing where a regexp gets parsed into a map, but do it before writing and turn all our libraries’ logs into edn maps.

ddeaguiar18:05:55

@jfntn lnav supports different formats and provides many predefined ones. It uses the format that matches the current log file.

ddeaguiar19:05:03

you can get as fancy as you like

ddeaguiar19:05:40

you can also configure it to work with Papertrail although I’ve not tried that

kenny22:05:18

I can't quite figure out why if I include io.pedestal.http/dev-interceptors , I always get a 403 Forbidden with any of my routes even though I have set ::http/allowed-origins to (constantly true). Any ideas why this would be happening?

kenny22:05:10

The problematic interceptor is io.pedestal.http.cors/dev-allow-origin. Though, all it is doing is setting the request origin to an empty string if it doesn't exist. I don't see how that would affect the (constantly true) function.

kenny22:05:19

The interceptors in the service map that causes the 403 are these:

#Interceptor{:name :io.pedestal.http.impl.servlet-interceptor/exception-debug}
#Interceptor{:name :io.pedestal.http.cors/dev-allow-origin}
#Interceptor{:name :io.pedestal.http/log-request}
#Interceptor{:name :io.pedestal.http.cors/allow-origin}
#Interceptor{:name :io.pedestal.http/not-found}
#Interceptor{:name :io.pedestal.http.ring-middlewares/content-type-interceptor}
#Interceptor{:name :io.pedestal.http.route/query-params}
#Interceptor{:name :io.pedestal.http.route/method-param}
#Interceptor{:name :io.pedestal.http.secure-headers/secure-headers}
#Interceptor{:name :io.pedestal.http.route/router}
If I remove #Interceptor{:name :io.pedestal.http.cors/dev-allow-origin} everything works A-OK.

kenny22:05:33

I figured it out... I called default-interceptors before I overrode the ::http/allow-origins key.

bherrmann23:05:58

boo cant destructure …. [{:keys parama paramb} (:params request)] wont work as params are strings…..

jfntn23:05:04

@bherrmann you can use :strs instead of :keys

jimmy00:05:13

jfntn: wow ! I just learn something new today 😄