Fork me on GitHub
#reitit
<
2020-04-26
>
amarus01:04:44

Hi! Does someone have example simple frontend-backend CRUD project with reitit? I cannot understand how to interact from frontend to backend rest api. May I just use simple http requests from frontend route handlers to bakend?

bartuka02:04:54

hi @alishermatkurbanov040, in the oficial repository has some examples there, have you looked at? https://github.com/metosin/reitit/tree/master/examples/frontend

lsenjov03:04:27

Reitit itself doesn't do much by itself, but it's a useful library to be used by other parts

mkvlr08:04:15

A good chunk of our frontend init time is spent creating the router. We have a total of 130 routes and quite a few of them conflict since we have github-style routes /:profile-handle/:article-name which predate us switching to reitit. Is there a way to do this work ahead of time?

orestis09:04:54

Oh wow. I was wondering if the performance trade offs reitit makes apply also to front end. Seems like the performance focus for frontend should rather be to amortize the cost over time, rather than at init time. Still, you have to somehow route at init too so not sure about ways to optimize this.

orestis09:04:19

@mkvlr how many routes are you dealing with?

ikitommi10:04:24

Looking at the code, the conflict resolution is run twice, should be easy win to fix that. Also, there doesn't seem to be a way to totally disable the conflict resolution, one could just use linear-router and get fast startup and bit slower routing.

ikitommi10:04:45

If you define the router via def, shouldn't it be precalculated?

ikitommi10:04:45

I could fix the two small things later today. The router creation is not perf optimized currently ..

mkvlr10:04:57

I do have the router defined in a def

mkvlr10:04:55

being able to specify the router implementation as an opt would go good for our use case I guess

mkvlr10:04:45

seems it should be possible with the public api also, but I must have done something wrong when I tried

mkvlr11:04:02

no rush at all btw, we’ve lived with this for a while, just recently discovered it and thought I’d ask

Marcus18:04:07

Hello all! I'm fairly new to clojure and reitit. I am trying to set up a ring/swagger service. Is there a way to have the default edn in both requests and responses? When I do a request now with accept = application/edn I still get a application/json response that must be decoded. E.g. {:status 200, :body #object[http://java.io.ByteArrayInputStream 0x68a954f9 "http://java.io[email protected]"], :headers {"Content-Type" "application/json; charset=utf-8"}}.

ikitommi19:04:39

@marcus.akre could you paste the request you are sending? if accept is edn, it should return it in that.

ikitommi19:04:24

@mkvlr did a small spike on router creation perf. It’s crap 🙂 Here’s a PR for making it bit better: https://github.com/metosin/reitit/pull/389

Marcus19:04:39

@ikitommi

(app {:request-method :get
    :uri "/plus"
      :query-params {:x 1 :y 2}}
     ))

Marcus19:04:47

:swagger {:produces #{"application/edn"}
                        :consumes #{"application/edn"}}

Marcus19:04:05

in the swagger ui the only option is edn

Marcus19:04:36

If I query with accept = edn it works fine. actually

Marcus19:04:51

(via http client that is)

mkvlr19:04:17

@ikitommi thank you! Will give it a try tomorrow and let you know. Thanks again!