-
Notifications
You must be signed in to change notification settings - Fork 568
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
Static content support module. #2705
Static content support module. #2705
Conversation
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.
Shouldn't this PR be targeted for 3.x ? It breaks compatibility right ?
I have only created a new module and deprecated the old classes. Everything still works as it used to. |
Will need to incorporate changes from #2686 if we decide to merge them |
Check #2631 We should support a fallback to a single file from static content. Request to This would allow for routing like this:
|
Signed-off-by: Tomas Langer <[email protected]>
Signed-off-by: Tomas Langer <[email protected]>
- fixes false positives due to try with resources - fixed MediaType as it triggered a bug Signed-off-by: Tomas Langer <[email protected]>
Support for single file handling. Signed-off-by: Tomas Langer <[email protected]>
96853eb
to
b4437be
Compare
Refactored implementation to have nicer builders, added integration tests to validate implementation. |
Signed-off-by: Tomas Langer <[email protected]>
Signed-off-by: Tomas Langer <[email protected]>
Signed-off-by: Tomas Langer <[email protected]>
...static-content/src/main/java/io/helidon/webserver/staticcontent/FileBasedContentHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Tomas Langer <[email protected]>
return Routing.builder() | ||
.register("/simple", classpath) | ||
.register("/fallback", classpath) | ||
.register("/fallback", StaticContentSupport.builder("fallback") |
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.
Maybe a minor thing, but fallback/index.html
will be extracted twice to the tmp directory when using two separate instances.
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.
I do not think this is the case. There is one based on classpath, one based on path.
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.
This is a side-effect of the current implementation of the classpath based StaticContentSupport
.
Signed-off-by: Tomas Langer <[email protected]>
Signed-off-by: Tomas Langer <[email protected]>
...er/static-content/src/main/java/io/helidon/webserver/staticcontent/StaticContentHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Tomas Langer <[email protected]>
Signed-off-by: Tomas Langer <[email protected]>
Resolves #1869
Resolves #1236
Resolves #2631
Resolves #2764
There is a new module:
helidon-webserver-static-content
.Entry point is
io.helidon.webserver.staticcontent.StaticContentSupport.builder(..)
To achieve a fallback for static content, you can use the following when setting up routing:
This will resolve any request to
/static
as follows:web
, usingindex.txt
as the welcome file for directory requestsfallback/index.txt
for any request that does not find a resource in the first stepThe default
pathMapper
does not modify the path (so forstatic/css/company.css
it returnsstatic/css/company.css
).There is a known duplicate use of temporary directory - each instance of static content support based on classpath would extract the files separately. If we used the same classpath location to read the "fallback" file, it would be extracted and cached twice.
As this use-case is based on the need to have a single backup file, the impact is minimal (extracting one extra file). If this is a major performance issue for your application, please submit a new issue with your use case.