funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
kenny 2016-01-13T20:52:55.000265Z

@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.

kenny 2016-01-13T21:05:47.000266Z

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"]}]]

niwinz 2016-01-13T22:13:42.000267Z

Good question

niwinz 2016-01-13T22:14:00.000268Z

I think that there are two possible solutions.

niwinz 2016-01-13T22:16:07.000269Z

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

niwinz 2016-01-13T22:16:24.000270Z

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

niwinz 2016-01-13T22:16:52.000271Z

and an other option is

niwinz 2016-01-13T22:16:58.000272Z

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

niwinz 2016-01-13T22:17:07.000273Z

Putting this on the end of the pipeline

niwinz 2016-01-13T22:17:58.000274Z

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

kenny 2016-01-13T22:18:26.000275Z

I'll test it out and let you know

👍 1
niwinz 2016-01-13T22:24:53.000276Z

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

niwinz 2016-01-13T22:36:29.000277Z

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 😉

niwinz 2016-01-13T22:36:38.000278Z

and now I'm go away

kenny 2016-01-13T22:37:08.000279Z

Awesome thanks! :simple_smile:

✅ 1