Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We should be able to add / and /* to RouterService #52

Open
sbernard31 opened this issue May 3, 2023 · 5 comments
Open

We should be able to add / and /* to RouterService #52

sbernard31 opened this issue May 3, 2023 · 5 comments

Comments

@sbernard31
Copy link
Collaborator

Currently this is not possible to do :

RouterService.RouteBuilder routerBuilder = new RouterService.RouteBuilder();
routerBuilder //
        .any("/", new RootResource() //
        .any("/myResource", new MyResource() //
        .any("/*", new Default());
router = routerBuilder.build();

If you do that RootResource will never be called.
I think this is because / and /* will create 2 RequestMatcher which will be considered as equal and so Default will override RootResource in handlers hashmap.
Maybe the solution is to add isPrefixed attribute to equals() and hashcode() methods ?

(triggered by #27 (comment))

@sbernard31
Copy link
Collaborator Author

Not directly linked but not sure to get why isPrefixed is transient ? 🤔

static final class RequestMatcher {
    private final Method method;
    private final String uriPath;
    private transient final boolean isPrefixed;

@szysas
Copy link
Collaborator

szysas commented May 3, 2023

Well, that transient was to prevent adding isPrefixed to equals method.

@sbernard31
Copy link
Collaborator Author

Oh I was thinking transient was about Java Serialization. Not sure to know how this is related to equals ? Maybe something related to IDE code generation ?

@szysas
Copy link
Collaborator

szysas commented May 3, 2023

That is needed by this testing tool: https://jqno.nl/equalsverifier/ to skip fields from being tested.

@sbernard31
Copy link
Collaborator Author

Oh I didn't know about EqualsVerifier maybe this is a library we should use in Leshan 🤔

About transient, I read documentation : https://jqno.nl/equalsverifier/manual/ignoring-fields/#transient-fields and they also talk about serialization maybe it make more sense to use : https://jqno.nl/equalsverifier/manual/ignoring-fields/#ignoring-fields
(but clearly this is very small details)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants