clojure-uk

A place for people in the UK, near the UK, visiting the UK, planning to visit the UK or just vaguely interested to randomly chat about things (often vi and emacs, occasionally clojure). More general the #ldnclj
dharrigan 2020-12-16T06:16:41.189700Z

Good Morning!

thomas 2020-12-16T08:08:17.189900Z

mogge

dominicm 2020-12-16T08:23:47.190200Z

Morning

djm 2020-12-16T08:44:13.191400Z

👋 Thursday last week was my last day of work for the year - nice to have a relaxing finish to the year.

alexlynham 2020-12-16T08:55:46.191500Z

morning

mccraigmccraig 2020-12-16T08:59:28.191700Z

månmån

alexlynham 2020-12-16T10:17:47.191800Z

morning

alexlynham 2020-12-16T10:18:02.191900Z

FWIW i prefer routes defined as functions that take maps

alexlynham 2020-12-16T10:18:11.192Z

i like being able to execute them in the repl

alexlynham 2020-12-16T10:18:20.192100Z

i like being able to unit test them like regular fns

dominicm 2020-12-16T10:25:17.192700Z

Oh, you're all talking about handlers, not routers.

mccraigmccraig 2020-12-16T10:59:29.193900Z

how does every route as a function work @jiriknesl? do they get called in sequence until one says yes ?

dharrigan 2020-12-16T20:41:05.194600Z

Is it common, if you have a map and a value to a key is a function, to name the key something like foo-bar-fn?

dharrigan 2020-12-16T20:41:27.195200Z

{:foo-bar-fn (fn [x y] (+ x y))} for example

dharrigan 2020-12-16T20:41:37.195400Z

or simply

dharrigan 2020-12-16T20:41:53.195600Z

{:foo-bar (fn [x y] (+ x y))}

seancorfield 2020-12-16T20:46:54.196400Z

@dharrigan I lean toward -fn (and you'll see that in next.jdbc and elsewhere in my OSS code) but I don't know how widespread that is...

mccraigmccraig 2020-12-17T08:11:44.204600Z

i find it especially helpful in code where you have both wrapped and unwrapped versions of something floating around

dharrigan 2020-12-16T20:47:05.196700Z

thank you

dharrigan 2020-12-16T20:47:16.197Z

I think I agree, it makes it clearer what the key is about

jiriknesl 2020-12-16T22:14:24.199300Z

@mccraigmccraig as @dharrigan says, your route is a triplet of name (keyword), url->action (fn), action->url (fn). Action route goes through all url->action which either return controller action with params or nothing. The last in a row is default catchall error router.

dominicm 2020-12-16T22:41:31.199400Z

That sounds very slow :)

dominicm 2020-12-16T22:41:44.199500Z

Also, how do you build your sitemap automatically!

jiriknesl 2020-12-16T22:46:28.200400Z

It is not slower than Sinatra’s get '/' do … end or equivalent in almost all other frameworks out there.

jiriknesl 2020-12-16T22:46:59.201Z

For a sitemap, every router could potentially enumerate all routes the router is aware of.