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

Explore Jetty-free implementation of resource handler #2157

Open
dzikoysk opened this issue Feb 28, 2024 · 3 comments
Open

Explore Jetty-free implementation of resource handler #2157

dzikoysk opened this issue Feb 28, 2024 · 3 comments

Comments

@dzikoysk
Copy link
Member

Context

Currently, our static files api directly depends on Jetty's resource handler. It's a bit painful, because this implementation is relatively complex itself (because it works directly on Jetty's API) and it's one of the main blockers before exploring the possibility to use other http servers.

Requirements

The new implementation should:

  • Be fully compatible with current static API
  • Cover security related concerns to filter out malicious requests
  • Do not depend on Jetty and Jakarta EE servlet's API
@Jerbell
Copy link
Contributor

Jerbell commented Aug 23, 2024

Hi @dzikoysk What would it take for a simple implementation here? Like a ClasspathResourceHandler which took in the directory where the files are, the match/url path & headers added. Would it still be difficult? I've seen the JettyResourceHandler but it looks quite complicated. Overly complicated perhaps?

@dzikoysk
Copy link
Member Author

Hey, I remember @zugazagoitia did some work on exploring this topic, so maybe he could add some extra feedback on what we actually need to cover that. I personally didn't touch this part of Javalin that much, because I don't really use this feature on my own.

@zugazagoitia
Copy link
Member

There are two main issues expanding on the ones @dzikoysk mentioned in the OP:

  • Not breaking compatibility with the current handling of routes. Any new implementation might break how files are resolved in the clients in unexpected or non-intuitive ways.
  • I had some trouble also handling webjar resources, which required a bit of a messy implementation.

I've seen the JettyResourceHandler but it looks quite complicated.

You are completely right about this, it is more complicated than it should. If you have the time and will please give it a shot and see how far you get! I currently don't have the time to keep working on it unfortunately.

A minimal implementation should just implement the ResourceHandler interface and offer the same config and compressing functionality (precompressing can easily be added after).

Optimally we would in future versions implement smarter caching, but not a big issue now either. If you want to explore this further we're available also in Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants