lapis icon indicating copy to clipboard operation
lapis copied to clipboard

How to pass request from 'access' phase to 'content' phase?

Open uudiin opened this issue 9 years ago • 1 comments
trafficstars

I use 'access' phase for check permission, like this:

access_by_lua   'require("lapis").serve("access")';
content_by_lua  'require("lapis").serve("app")';

But the undeclared routes in 'access' phase can't be passed to 'content' phase, What should I do? Thanks very much.

uudiin avatar Nov 16 '16 08:11 uudiin

Hmm, I didn't really plan for lapis to be used in the access phase, since a app will write something by default. Apps exist separate from each other, so you can't generate urls across them.

You can load the app manually and generate a URL like this:

local app = require("app")()
app:url_for("some_route", {hello = "world"})

Note that using the above method will not take advantage of a url_params method on an object passed to url_for: http://leafo.net/lapis/reference/actions.html#request-object-methods/url_for/passing-an-object-to-url-for

leafo avatar Dec 07 '16 00:12 leafo