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

4.x: Static content from classpath improvements #9471

Open
tomas-langer opened this issue Nov 6, 2024 · 3 comments · May be fixed by #9502
Open

4.x: Static content from classpath improvements #9471

tomas-langer opened this issue Nov 6, 2024 · 3 comments · May be fixed by #9502
Assignees
Labels
4.x Version 4.x enhancement New feature or request P2 webserver
Milestone

Comments

@tomas-langer
Copy link
Member

Currently we generate temporary files for extracted jar entries as ws-****.je

A few improvements could be done:

  • use helidon- (or helidon-ws) prefix to clearly bind them to Helidon
  • add configuration option to cache in-memory only (probably to a certain size), to avoid creating the files altogether
@github-project-automation github-project-automation bot moved this to Triage in Backlog Nov 6, 2024
@tomas-langer tomas-langer added the 4.x Version 4.x label Nov 6, 2024
@m0mus m0mus added enhancement New feature or request P2 labels Nov 7, 2024
@m0mus m0mus moved this from Triage to Sprint Scope in Backlog Nov 7, 2024
@hrstoyanov
Copy link
Contributor

Is it possible to process the files as they are extracted from the class path? For example, CSS files may have comments, that I might not want to serve to the client , and would like to strip off.

@tomas-langer
Copy link
Member Author

Is it possible to process the files as they are extracted from the class path? For example, CSS files may have comments, that I might not want to serve to the client , and would like to strip off.

I think this should be done at build time and your deployment should contain the files you want to serve (minified css, javascript etc.).

Also Helidon does not have such a feature, as we need to work with the content length of the file (i.e. when a range is requested, to correctly provide Content-Length header etc.). Such operations would introduce quite an overhead (I can imagine this being implemented, but I would rather not)

@tomas-langer
Copy link
Member Author

The PR will have the following updates:

  • support for configuration based setup of static content (currently only possible through API)
  • introduces static content server feature to do so (can be used programmaticaly and through config)
  • introduces more configurable temporary storage (enabled, location, prefix, suffix), shared by all handlers, with possibility to customize per handler
  • introduces more configurable memory storage (enabled, maximal size in bytes), shared by all handlers, with possibility to customize per handler
  • when using classpath, if cached in memory, no temporary file gets created
  • when using classpath, when using temporary files, we have a shutdown hook to delete them
  • when using classpath, when temporary storage is disabled, files are served directly from jar input stream

Example of a configuration:

server:
  features:
    # the new static content feature, automatically discovered
    static-content:
      # (optional) configuration of temporary storage
      temporary-storage:
        directory: "./target/helidon/tmp"
        file-prefix: "helidon-custom"
        file-suffix: ".cache"
        # delete-on-exit: false
      # classpath handlers (context to serve on webserver and location on classpath)
      classpath:
        - context: "/classpath"
          location: "web"
        - context: "/singleclasspath"
          location: "web/resource.txt"
      # file system handlers (context to serve on webserver and location on file system)
      path:
        - context: "/path"
          location: "./src/test/resources/web"
        - context: "/singlepath"
          location: "./src/test/resources/web/resource.txt"

@tomas-langer tomas-langer linked a pull request Nov 21, 2024 that will close this issue
@tomas-langer tomas-langer added this to the 4.1.5 milestone Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x enhancement New feature or request P2 webserver
Projects
Status: Sprint Scope
Development

Successfully merging a pull request may close this issue.

3 participants