webmcp

view framework/env/request/redirect.lua @ 562:328f120924a2

Removed if-clause when initializing file descriptor set to avoid compiler warning for mondelefant_conn_try_wait
author jbe
date Fri Feb 05 15:51:39 2021 +0100 (2021-02-05)
parents e2389cc82214
children
line source
1 --[[--
2 request.redirect{
3 external = external, -- external URL (instead of specifying base, module, etc. below)
4 base = base, -- optional string containing a base URL of a WebMCP application
5 static = static, -- an URL relative to the static file directory
6 module = module, -- a module name of the WebMCP application
7 view = view, -- a view name of the WebMCP application
8 action = action, -- an action name of the WebMCP application
9 id = id, -- optional id to be passed to the view or action to select a particular data record
10 params = params, -- optional parameters to be passed to the view or action
11 anchor = anchor, -- anchor in URL
12 include_tempstore = include_tempstore -- set to true to include slot data via _tempstore param (defaults to true unless external is set)
13 }
15 Calling this function causes the WebMCP to do a 303 HTTP redirect after the current view or action and all filters have finished execution. If routing mode "redirect" has been chosen, then this function is called automatically after an action and all its filters have finished execution. Calling request.redirect{...} (or request.forward{...}) explicitly inside an action will cause routing information from the browser to be ignored. To preserve GET/POST parameters of an action, use request.forward{...} instead. Currently no redirects to external (absolute) URLs are possible, there will be an implementation in future though.
17 --]]--
19 function request.redirect(args)
20 args = table.new(args)
21 if type(args.external) ~= "string" and type(args.static) ~= "string" then
22 if type(args.module) ~= "string" then
23 error("No module string passed to request.redirect{...}.")
24 end
25 if type(args.view) ~= "string" then
26 error("No view string passed to request.redirect{...}.")
27 end
28 if args.params ~= nil and type(args.params) ~= "table" then
29 error("Params array passed to request.redirect{...} is not a table.")
30 end
31 if args.anchor ~= nil and type(args.anchor) ~= "string" then
32 error("Anchor passed to request.redirect{...} must be a string or nil.")
33 end
34 end
35 if request.is_rerouted() then
36 error("Tried to redirect after another forward or redirect.")
37 end
38 request._redirect = args
39 if args.module and args.view then -- TODO: support for external redirects
40 trace.redirect{ module = args.module, view = args.view }
41 end
42 end

Impressum / About Us