Fork me on GitHub
#reitit
<
2018-11-17
>
mike_ananev10:11:20

Hello. I'm using reitit 2.7. I'm trying to create nested path with handlers. Can't understand why all intermediate handlers are ignored?

mike_ananev10:11:59

I can invoke only "/test1/test2" handler. Why I can't invoke "/test1" handler?

ikitommi11:11:29

@mike1452 handlers are request => response functions, so you can compose them. You should use Interceptors for that, as all the steps are context => ->context, so you can chain them.

mike_ananev11:11:54

@ikitommi A, thanks. Now I understand the logic.

ikitommi11:11:11

behind the scenes, all intermediate data is meta-merged into endpoints: Interceptors are defined in vector, and thet get conjoined. handlers are defined as functions, so the last one wins

mike_ananev11:11:38

but anyway I've achieved desired behaviour by this code.

👍 4
ikitommi11:11:51

you can ask the merged final route tree (with data) from the router to see how it looks

ikitommi11:11:37

Oh, there was a discussion to allow the intermediate paths with handlers to function as endpoints too. Can't remember how it ended. If you wish this, please write an issue.

mike_ananev12:11:41

here is a full example. now, i have handlers on any level, all intermediate interceptors are executed.

ikitommi18:11:10

also, copied from c-api the new spec error handling: the spec problems will be available in the error handlers, so one can plug in expound, pinpointer or any other spec pretty printer to handle spec errors.

👍 4
ro619:11:53

has anyone else had this bug where the body editor part of the Swagger-UI doesn't render?

ro619:11:43

I'm trying to migrate from compojure-api to reitit 0.2.7 and all I see is:

ikitommi19:11:46

@robert.mather.rmm have you defined both :coercion and :parameters &/ :responses?

ro619:11:57

:coercion under :data in the top-level ring/router, only :parameters at the leaf/handler

ikitommi19:11:01

sounds legit. there is a working example in https://github.com/metosin/reitit/blob/master/examples/ring-swagger/src/example/server.clj. hope this helps, going offline now.

ro619:11:26

k, thanks. That's what I've been following. I'll keep poking around