-
-
Notifications
You must be signed in to change notification settings - Fork 638
feat: Add route roles for static files #2403
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
Conversation
|
Thanks @hupender - would be really great with some tests for this! |
|
Seems the implementation is making some of the existing tests fail too - you can run these locally by doing |
|
@tipsy i have made the changes and added unit test cases but getting failure in javalin-osgi. It was already failing even in the master branch. Details
|
|
I can do a complete test run without errors.
Details
|
|
@tipsy i have fixed the unit test cases. |
|
Thanks - running again ! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2403 +/- ##
============================================
+ Coverage 87.20% 87.21% +0.01%
- Complexity 1334 1340 +6
============================================
Files 148 148
Lines 4493 4506 +13
Branches 513 516 +3
============================================
+ Hits 3918 3930 +12
- Misses 363 364 +1
Partials 212 212 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@tipsy Something is wrong with codecov. https://app.codecov.io/gh/javalin/javalin |
|
Thanks guys - I'll have a look to see what's happened here on sunday. |
|
Codecov is fixed - I rebased the PR too. Will have a look now. |
| val willMatch by javalinLazy { | ||
| var routeRoles: Set<RouteRole> = servlet.matchedRoles(ctx, requestUri) | ||
| if (httpHandlerOrNull == null && (ctx.method() == HEAD || ctx.method() == GET)) { | ||
| routeRoles = servlet.cfg.pvt.resourceHandler?.getResourceRouteRoles(ctx) ?: emptySet() | ||
| } | ||
| ctx.setRouteRoles(routeRoles) // set roles for the matched handler | ||
| servlet.willMatch(ctx, requestUri) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| val willMatch by javalinLazy { | |
| var routeRoles: Set<RouteRole> = servlet.matchedRoles(ctx, requestUri) | |
| if (httpHandlerOrNull == null && (ctx.method() == HEAD || ctx.method() == GET)) { | |
| routeRoles = servlet.cfg.pvt.resourceHandler?.getResourceRouteRoles(ctx) ?: emptySet() | |
| } | |
| ctx.setRouteRoles(routeRoles) // set roles for the matched handler | |
| servlet.willMatch(ctx, requestUri) | |
| } | |
| val isResourceHandler = httpHandlerOrNull == null && ctx.method() in setOf(HEAD, GET) | |
| val matchedRouteRoles by javalinLazy { servlet.matchedRoles(ctx, requestUri) } | |
| val resourceRouteRoles by javalinLazy { servlet.cfg.pvt.resourceHandler?.getResourceRouteRoles(ctx) ?: emptySet() } | |
| val willMatch by javalinLazy { | |
| ctx.setRouteRoles(if (isResourceHandler) resourceRouteRoles else matchedRouteRoles) | |
| servlet.willMatch(ctx, requestUri) | |
| } |
|
|
||
| override fun getResourceRouteRoles(ctx: Context): Set<RouteRole> { | ||
| nonSkippedHandlers(ctx.jettyReq()).forEach { handler -> | ||
| val target = ctx.target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use url decoder too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tipsy, yes we have to use decoder here as well and I have done all the suggested changes.
|
Thanks guys - sorry this is taking some time, I am in the process of moving houses. |
|
Thanks @hupender, this looks really great. Sorry again about the long wait, I just got my home office up and running. |


Provided feature for the issue #2364.
Example use case :