Skip to content

discussion: resolving requests to "/home" parents route should work if i give it a handler #747

@merveillevaneck

Description

@merveillevaneck

hi there. love the library, great work!

I just set up a small reitit router to test out a few things and noticed something about the behavior. I don't know if this is intentional, so opening a discussion point seemed to be a better idea than to just assume its a bug, since I was struggling to find anything in the documentation regarding this.

here is a screenshot of the example (note, in the example, the parent route is /home which is weird but bare with me, its just an example)

Image

as you can see, I am making a ring router and handler that uses /home as a parent in the path, with potential subroutes. nothing special just standard http. but then i expected the result to be as the expected-result def in the comment block below the router. (apply-generic here is just a set of standard default from ring defaults).

my question is: should i expect the above router to "just work" and resolve my request to "/home" simply by adding a handler using {:get {:handler home}}? ergo, should I expect a valid response from this router when requesting /home instead of nil?

the actual response is nil.

my 2 cents is I should expect it to work. as this is normal behavior in many http applications. though i have not built a router myself, so maybe there is some best practice im unaware of suggesting otherwise?

any explanation welcome?

P.S. if I explicitly define child paths as "" and "/" then it does work, but this is slightly annoying as I then have to define 2 paths for the parent instead of just one declared handler that catches both paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions