reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
athomasoriginal 2020-05-12T03:38:54.372700Z

In the https://github.com/metosin/reitit/blob/7f7d6e22565362ac2b1c21a413865bab38438bac/examples/frontend-auth/src/frontend/core.cljs the main-view screen ensures that protected routes aren’t rendered. However, with this implementation, if the user clicks “items” link the URL will still read http://0.0.0.0:3449/#/items while showing the login screen. Is there a recommendation on where to replace history so the URL also reads something like http://0.0.0.0:3449/#/login?

apa512 2020-05-12T17:21:22.374100Z

i'm trying to put certain routes under a subdomain but can't see any way to route based on host. is this at all possible using pedestal without running two separate servers?

ikitommi 2020-05-12T19:36:02.377100Z

@apa512 not supported out-of-the-box. But you could create a small pre-processor to do it.

ikitommi 2020-05-12T19:39:11.381200Z

something like: 1) create a router with forced bracket-syntax, full urls 2) read the compiled routes, split based on virtual host and create two routers & ring/http handlers and route to correct one based on virtual host

ikitommi 2020-05-12T19:40:11.382800Z

1 could just be arbitrary route data key too, like {:vhosts #{"dev" "test"}}.

ikitommi 2020-05-12T19:41:04.383800Z

should not be more than 10 lines on top of the current apis.

apa512 2020-05-12T19:42:12.384800Z

cool, does that mean ring handlers are compatible with pedestal?

Dave Simmons 2020-05-12T20:00:20.386500Z

Hi All. Does anyone have a really basic example of handling csrf in reitit. I've added wrap-anti-forgery to my middleware but everytime I do a post I get an invalid csrf token. If someone has an example of this working in reitit I'd be really grateful. Thanks.

Dave Simmons 2020-05-14T18:41:17.411100Z

Thought I'd reply to my own comment as I found my issue. In my app definition I'd added the :middleware wrap-session against ring/router when it should have been ring/ring-handler. The implication being that I never defined a session so my csrf wouldn't work.

ikitommi 2020-05-12T20:07:25.388900Z

@apa512 oh, pedestal. The same custom code should be in the routing-ibterceptor then (from reitit.pedestal)

apa512 2020-05-12T20:45:50.389400Z

@ikitommi thanks, i will check it out

ikitommi 2020-05-12T20:50:57.390300Z

[metosin/reitit "0.5.0-SNAPSHOT"] is on clojars, here’s the CHANGELOG: https://github.com/metosin/reitit/blob/master/CHANGELOG.md#050-snapshot

🎉 1
sudakatux 2020-05-13T12:41:24.393200Z

So just changing the version to [metosin/reitit "0.5.0-SNAPSHOT"] throwed a java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ser.std.ToStringSerializerBase

ikitommi 2020-05-13T12:42:49.393400Z

thank you Jackson. Could you list your (transitiv) dependencies?

ikitommi 2020-05-13T12:43:02.393600Z

e.g. lein deps :tree or such

sudakatux 2020-05-13T12:44:41.393800Z

sure

sudakatux 2020-05-13T12:47:23.394Z

ikitommi 2020-05-13T12:54:38.394400Z

Maven sucks at this: you have a direct dependency to Cheshire, which uses older version of Jackson, which is the shortest path, overriding the version from Jsonista, which, reitit uses (much faster). Jackson seems to break internally on every version.

ikitommi 2020-05-13T12:54:41.394600Z

[cheshire "5.8.1"] -> [com.fasterxml.jackson.core/jackson-core "2.9.6"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-interceptors "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-middleware "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-swagger-ui "0.5.0-SNAPSHOT"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-interceptors "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-interceptors "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-middleware "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-middleware "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-swagger-ui "0.5.0-SNAPSHOT"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-swagger-ui "0.5.0-SNAPSHOT"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-interceptors "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-middleware "0.5.0-SNAPSHOT"] -> [metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [metosin/reitit-swagger-ui "0.5.0-SNAPSHOT"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]
[org.webjars/webjars-locator "0.36"] -> [com.fasterxml.jackson.core/jackson-databind "2.9.8"] -> [com.fasterxml.jackson.core/jackson-core "2.9.8"]
[org.webjars/webjars-locator "0.36"] -> [org.webjars/webjars-locator-core "0.37"] -> [com.fasterxml.jackson.core/jackson-core "2.9.8"]
[metosin/reitit "0.5.0-SNAPSHOT"] -> [com.fasterxml.jackson.core/jackson-core "2.11.0"]

ikitommi 2020-05-13T12:54:47.394800Z

that says it all.

ikitommi 2020-05-13T12:55:31.395Z

only way to fix that is: a) get Cheshre to use the latest version b) manually add [com.fasterxml.jackson.core/jackson-core "2.11.0"] as dependency, it’s the shortest path and overrides everything

sudakatux 2020-05-13T12:56:01.395200Z

cool will give that a try thanks

sudakatux 2020-05-13T13:00:29.395400Z

hmm... i did both and still get the same exception

sudakatux 2020-05-13T13:01:00.395600Z

i updated Cheshre and manually added [com.fasterxml.jackson.core/jackson-core "2.11.0"]

ikitommi 2020-05-13T13:01:19.395800Z

what does the deps tree say now?

ikitommi 2020-05-13T13:14:47.396Z

https://github.com/dakrone/cheshire/pull/164

ikitommi 2020-05-13T13:14:57.396300Z

https://github.com/dakrone/cheshire/issues/163

sudakatux 2020-05-13T14:29:19.396600Z

ha wow you move fast

sudakatux 2020-05-13T14:29:41.396800Z

thanks

ikitommi 2020-05-12T20:52:08.391500Z

Almost would like to rollback the swagger-ui back to 2.*. Not a fan of the new one.