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

Routes behavior with&without a root (/) route is inconsistent #258

Open
joelsdc opened this issue Jun 28, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@joelsdc
Copy link

commented Jun 28, 2019

What version of aah are you using (aah --version)?

v0.12.3

Does this issue reproduce with the latest release?

Yes

What operating system are you using (such as macOS, Linux and Windows)?

macOS (haven't verified the bug on other platforms)

What did you do?

Create a simple service that has only one route not directly under the root path.

Example routes.conf:

    routes {
      test {
        path = "/test/:something"
        controller = "SomeController"
        action = "SomeAction"
        }
      }
    }

What did you expect to see?

I expected that any path that wouldn't match .../test/something aah should return a 404, and the log should state a "route not found".

Expected:

GET http://localhost:8080 --> Route not found, Host: localhost:8080, Path: /
GET http://localhost:8080/ --> Route not found, Host: localhost:8080, Path: /
GET http://localhost:8080/a --> Route not found, Host: localhost:8080, Path: /a
GET http://localhost:8080/b --> Route not found, Host: localhost:8080, Path: /b
GET http://localhost:8080/asdf --> Route not found, Host: localhost:8080, Path: /asdf
GET http://localhost:8080/t --> Route not found, Host: localhost:8080, Path: /t
GET http://localhost:8080/te --> Route not found, Host: localhost:8080, Path: /te
GET http://localhost:8080/test --> Route not found, Host: localhost:8080, Path: /test (??)
GET http://localhost:8080/test/asdf --> Calling action: xxx/SomeController.SomeAction
GET http://localhost:8080/anything --> Route not found, Host: localhost:8080, Path: /anything
GET http://localhost:8080/something/else --> Route not found, Host: localhost:8080, Path: /something/else

NOTE: I have my doubts on what would the correct results be the line with (??)

What did you see instead?

I saw the following:

GET http://localhost:8080 --> Route not found, Host: localhost:8080, Path: /
GET http://localhost:8080/ --> Route not found, Host: localhost:8080, Path: /
GET http://localhost:8080/a --> Calling action: xxx/SomeController.SomeAction
GET http://localhost:8080/b --> Calling action: xxx/SomeController.SomeAction
GET http://localhost:8080/asdf --> Calling action: xxx/SomeController.SomeAction
GET http://localhost:8080/t --> Route not found, Host: localhost:8080, Path: /t
GET http://localhost:8080/te --> Route not found, Host: localhost:8080, Path: /te
GET http://localhost:8080/test --> Route not found, Host: localhost:8080, Path: /test
GET http://localhost:8080/test/asdf --> Route not found, Host: localhost:8080, Path: /test/asdf
GET http://localhost:8080/anything --> Calling action: xxx/SomeController.SomeAction
GET http://localhost:8080/something/else --> Route not found, Host: localhost:8080, Path: /something/else

Additional context

WORKAROUND: After extensive testing and trying crazy combinations I have found that if you have and "Index" route (/), this whole behavior changes:

Example2 routes.conf:

    routes {
      index {
        path = "/"
        controller = "DummyController"
        action = "DummyAction"
      }
      test {
        path = "/test/:something"
        controller = "SomeController"
        action = "SomeAction"
        }
      }
    }

We get the correct results:

GET http://localhost:8080 --> Calling action: xxx/DummyController.DummyAction
GET http://localhost:8080/ --> Calling action: xxx/DummyController.DummyAction
GET http://localhost:8080/a --> Route not found, Host: localhost:8080, Path: /a
GET http://localhost:8080/b --> Route not found, Host: localhost:8080, Path: /b
GET http://localhost:8080/asdf --> Route not found, Host: localhost:8080, Path: /asdf
GET http://localhost:8080/t --> Route not found, Host: localhost:8080, Path: /t
GET http://localhost:8080/te --> Route not found, Host: localhost:8080, Path: /te
GET http://localhost:8080/test --> Route not found, Host: localhost:8080, Path: /test
GET http://localhost:8080/test/asdf --> Calling action: xxx/SomeController.SomeAction
GET http://localhost:8080/anything --> Route not found, Host: localhost:8080, Path: /anything
GET http://localhost:8080/something/else --> Route not found, Host: localhost:8080, Path: /something/else

Please let me know if you need any other information.

Thanks!

@jeevatkm

This comment has been minimized.

Copy link
Member

commented Jun 29, 2019

@joelsdc I have read your details bug report. Thank you for explaining in detail.

I feel this is bug in the router when route / is not defined. Need investigation and fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.