> Can I use send_file together with a template ? Let's say I want to render
> html with an image,

Serving HTML and image for this HTML-page are 2 separate requests, you
can't send them together.

Using send_file seems not appropriate, because it sets
Content-disposition-header. Which means: browser downloads a file, but
you want to show it inside HTML.


I see, that's what I was suspecting.
 
> Any other ideas ?

For example, you may link this images directory symbolically into
session-named directory and use this name as prefix in your template.

This sounds as the solution for me, though it is not that flexible as the before hook.
Alternatively I can switch to Dancer 1:)
 

Another way (my preference) is to use some Plack middleware for
authorization and use it as gatekeeper which makes sure, that some
directories (or just files) are accessible only to certain (logged in)
users.

I use Dancer2::Plugin::Auth::Extensible and switching to another
authentication will make the whole thing more complicated, so for now I'll try to play with symlinks.

Thank you for your help.