[undertow-dev] Serving files in a different hierarchy than the one in the file system

Stuart Douglas sdouglas at redhat.com
Tue Feb 6 19:01:20 EST 2018


You could possibly
use io.undertow.server.handlers.resource.ResourceSupplier, and then use
PathResourceManager under the hood to actually return a path resource. If
all these files have a common root path you could basically create a
PathResourceManager that maps to this, and then use Map<String, Resource>
in the supplier.

Stuart

On Tue, Feb 6, 2018 at 9:06 PM, Johannes Ernst <jernst at indiecomputing.com>
wrote:

> I’m attempting to serve a bunch of static files, which exist in the file
> system, but in various directories that do not correspond to the URL
> namespace. Example:
>
> http://example.com/foo/one  =>  /var/lib/one/bar
> http://example.com/foo/two  =>  /var/lib/two/bar
>
> I have the mapping from incoming request URL to File to be served in a
> Map<String,File>. Now I’m attempting to hook up Undertow so it can serve
> those files according to my mapping, and I’m not entirely sure where to
> best plug this in without having to write loads of code.
>
> As far as I can tell, I would need to implement my version of
> ResourceManager and Resource, sort of like File/PathResource/Manager, but
> there’s a lot of code there, not all of which I understand, and it would
> perhaps turn into a maintenance nightmare on my end.
>
> I cannot see a straightforward way of overriding those classes either to
> “slide in” an alternate mapping.
>
> Is there a better way of doing this?
>
> Thanks,
>
>
>
> Johannes.
>
>
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20180207/98ffe891/attachment.html 


More information about the undertow-dev mailing list