You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhancement proposal: use Undertow's built-in handlers to serve static content #1346
Currently, a dedicated handler exists (GetDynamicContentHandler) for serving static content.
In case it is considered useful, another approach would be to assess the feasibility of using the Undertow's built-in handlers to serve static content, in particular the ResourceHandler.
Advantages: slight reduction of code-base size, possibility of caching on server side, slightly better performance (the Undertow implementation uses a statically initialized map of mime types, thus avoiding a long chain of if-then-else).
Disadvantages: not so easy to serve the html files in response to an http request that does not end with .html (at least so far I wasn't able to do it). I also didn't have time to find out if the Undertow handlers can handle also the templating part of GetDynamicContentHandler
The ResourceHandler can be added to the routes like this:
final int cacheTime = 86400; // seconds
ResourceManager classPathManager = new ClassPathResourceManager(HttpServer.class.getClassLoader(), "static");
ResourceManager resourceManager = new CachingResourceManager(100, 65536,
new DirectBufferCache(1024, 10, 10480), classPathManager, cacheTime);
ResourceHandler resourceHandler = new ResourceHandler(resourceManager);
resourceHandler.setCachable(Predicates.truePredicate());
resourceHandler.setCacheTime(cacheTime);
final PathHandler routes = new PathHandler();
routes.addPrefixPath("/", resourceHandler);
and the html file must be included in the http request: http://[hostname]:[port_number]/index.html
@vic0824 if you can find a way to make it work, I'd be happy to evaluate the switch. Or if you are using ArcadeDB to serve your static pages too, what about using the default handler for those in your app where you need more speed?
In the case of ArcadeDB, it's only for Studio, so it's not a big deal.
GetDynamicContentHandler is absolutely fine, there's nothing wrong with it.
In my project, I have created a new branch which uses MariaDB, to experiment with geometry types, and it seemed strange that I had to write my own handler for such a common task as serving static content, so I did a bit of research and found a way to do it with a few lines of code using the Undertow's ResourceHandler, and I wanted to share this info.
There is no real need to modify the current ArcadeDB handler.
Activity
lvca commentedon Nov 24, 2023
@vic0824 if you can find a way to make it work, I'd be happy to evaluate the switch. Or if you are using ArcadeDB to serve your static pages too, what about using the default handler for those in your app where you need more speed?
In the case of ArcadeDB, it's only for Studio, so it's not a big deal.
vic0824 commentedon Nov 25, 2023
GetDynamicContentHandler is absolutely fine, there's nothing wrong with it.
In my project, I have created a new branch which uses MariaDB, to experiment with geometry types, and it seemed strange that I had to write my own handler for such a common task as serving static content, so I did a bit of research and found a way to do it with a few lines of code using the Undertow's ResourceHandler, and I wanted to share this info.
There is no real need to modify the current ArcadeDB handler.
chore(deps): bump jline.version from 3.30.4 to 3.30.5 [skip ci]
chore(deps): bump neo4j-driver from 5.28.3 to 6.0.1 in /e2e-js [skip ci]
chore(deps-dev): bump testcontainers from 12.0.0 to 12.0.1 in /e2e-js…
chore(deps-dev): bump testcontainers from 12.0.0 to 12.0.1 in /e2e-st…
chore(deps): bump jline.version from 3.30.4 to 3.30.5 [skip ci]
chore(deps): bump neo4j-driver from 5.28.3 to 6.0.1 in /e2e-js [skip ci]
chore(deps-dev): bump testcontainers from 12.0.0 to 12.0.1 in /e2e-js…
chore(deps-dev): bump testcontainers from 12.0.0 to 12.0.1 in /e2e-st…