GeezerVison is showing github.com — Enhancement proposal: use Undertow's built-in handlers to serve static content · Issue #1346 · ArcadeData/arcadedb
Enhancement proposal: use Undertow's built-in handlers to serve static content #1346DescriptionCurrently, 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 Activitylvca commented on 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 commented on 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|