Fork me on GitHub
#funcool
<
2016-01-13
>
kenny20:01:55

@niwinz: How would you recommend placing static assets under a "guarded" route (a route that requires authentication in order to be used). I have a authentication checking handler but I cannot use it in combination with :assets.

kenny21:01:47

It is possible to do the this but it requires that your static assets sit under some sort of endpoint when I do not want them to be under any endpoint.

[:prefix "app"
      [:any #'handlers/require-auth]
      [:assets "" {:dir     "target"
                   :indexes ["index.html"]}]]

niwinz22:01:42

Good question

niwinz22:01:00

I think that there are two possible solutions.

niwinz22:01:07

[[:prefix "assets"
  [:any auth-handler]
  [:assets "" opts]]]

niwinz22:01:24

this is an option but I don't know if it will work.

niwinz22:01:52

and an other option is

niwinz22:01:58

[[:scope
  [:any auth-handler]
  [:assets "assets" opts]]]

niwinz22:01:07

Putting this on the end of the pipeline

niwinz22:01:58

If nothing of that does not works. Tomorrow with calm I will fix it properly.

kenny22:01:26

I'll test it out and let you know

niwinz22:01:53

As far as I can understand the ratpack code the first method should work

niwinz22:01:29

I have read a little bit about how it works and surelly for the next version I will add facilities for build own handlers for serving assets allowing user fully control over file serving 😉

niwinz22:01:38

and now I'm go away

kenny22:01:08

Awesome thanks! simple_smile