Welcome the channel on the development of Cro, a set of libraries for building reactive distributed systems, lovingly crafted to take advantage of all the Raku Programming Language has to offer (cro.services). This channel is being logged for historical purposes. Set by lizmat on 24 May 2021. |
|||
Xliff | japhb: Ah! OK. Thanks | 05:27 | |
OK, I'm getting an error from Cro when attempting to implement a begin middleware... | 05:28 | ||
Can only use 'include' with `route` block, not a Cro::CompositeTransform::WithConnectionState | |||
Can someone please help? | |||
lizmat | Xliff: sorry, doesn't ring a bell with me perhaps jnthn or sena_kun | 06:46 | |
08:07
sena_kun joined
|
|||
jnthn | Typically means you need to use delegate, not include. It's mentioned in the docs cro.services/docs/reference/cro-ht...oute_block | 08:59 | |
Well, might also need before-matched and to stick with `include`, see the docs to figure out which goes with your situation. | 09:00 | ||
12:26
jgaz left,
jgaz joined
13:23
andinus left
|
|||
Xliff | 'I'm trying to apply a before middleware. I'm using "before -> { &my-code() }" in a route block. I do not want to use before-matched, because I am trying to debug why a route isn't being matched. | 13:36 | |
If I use the above code. I get the error referenced above. | |||
14:01
xinming joined
14:07
sena_kun left
14:10
sena_kun joined,
sena_kun left
14:11
sena_kun joined
14:44
xinming left
14:46
xinming joined
|
|||
jnthn | Xliff: Then, for the reason described in the docs, you can't use `include`; you need to use `delegate` instead. | 15:21 | |
Xliff | So... delegate { route { before => { ... } }; }; ? | 15:26 | |
The thing is, I want my before middleware to handle routes at the level I am currently. in. Delegation looks like it will handle blocks in a descendant node. | 15:28 | ||
Is it possible to apply a delegate at the same level as the current routes? | 15:29 | ||
And if I use a before call, what classes/roles must be implemented? | 15:30 | ||
jnthn | Yes, include is the flattening approach, and delegate is descendant, but that's the very point: if you want middleware to apply to everything in a route block regardless of if it matches, then that implies descendant mode. | 15:44 | |
Ah, maybe you mean you want `delegate` to not add a path prefix? But that won't work because how would it know which requests to delegate? | 15:45 | ||
17:17
xinming left
|
|||
Xliff | jnthn: All I want is a way log the URIs of each incoming request. | 17:35 | |
And whether or not they were matched. | |||
17:56
sena_kun left
18:05
sena_kun joined
19:23
[Coke] left
19:25
Xliff left,
[Coke] joined
21:17
sena_kun left
|
|||
jnthn | Can probably do that with: get -> *@not-matched { note "Didn't match {request.target}"; not-found; } | 21:20 | |
(and post/put/delete as needed) | 21:21 |