Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Introduced ResourcesRoute.requestRelativePath(request) utility method
- Loading branch information
Showing
with
5 additions
and
1 deletion.
-
+5
−1
restx-core/src/main/java/restx/ResourcesRoute.java
|
@@ -108,7 +108,7 @@ public ResourcesRoute(String name, String baseRestPath, String baseResourcePath, |
|
|
|
|
|
@Override |
|
|
public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { |
|
|
String relativePath = req.getRestxPath().substring(baseRestPath.length()); |
|
|
String relativePath = this.requestRelativePath(req); |
|
|
relativePath = Optional.fromNullable(aliases.get(relativePath)).or(relativePath); |
|
|
try { |
|
|
URL resource = MoreResources.getResource( |
|
@@ -130,6 +130,10 @@ public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp |
|
|
} |
|
|
} |
|
|
|
|
|
protected String requestRelativePath(RestxRequest req) { |
|
|
return req.getRestxPath().substring(baseRestPath.length()); |
|
|
} |
|
|
|
|
|
protected Optional<CachedResourcePolicy> cachePolicyMatching(String contentType, String path) { |
|
|
for(CachedResourcePolicy cachedResourcePolicy : cachedResourcePolicies){ |
|
|
if(cachedResourcePolicy.matches(contentType, path)){ |
|
|