jbe/bsw@0: --[[-- jbe/bsw@0: request.redirect{ jbe@267: external = external, -- external URL (instead of specifying base, module, etc. below) jbe@267: base = base, -- optional string containing a base URL of a WebMCP application jbe@267: static = static, -- an URL relative to the static file directory jbe@267: module = module, -- a module name of the WebMCP application jbe@267: view = view, -- a view name of the WebMCP application jbe@267: action = action, -- an action name of the WebMCP application jbe@267: id = id, -- optional id to be passed to the view or action to select a particular data record jbe@267: params = params, -- optional parameters to be passed to the view or action jbe@267: anchor = anchor -- anchor in URL jbe/bsw@0: } jbe/bsw@0: jbe/bsw@0: 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. jbe/bsw@0: jbe/bsw@0: --]]-- jbe/bsw@0: jbe/bsw@0: function request.redirect(args) jbe@267: args = table.new(args) jbe@267: if type(args.external) ~= "string" and type(args.static) ~= "string" then jbe@267: if type(args.module) ~= "string" then jbe@267: error("No module string passed to request.redirect{...}.") jbe@267: end jbe@267: if type(args.view) ~= "string" then jbe@267: error("No view string passed to request.redirect{...}.") jbe@267: end jbe@276: if args.params ~= nil and type(args.params) ~= "table" then jbe@267: error("Params array passed to request.redirect{...} is not a table.") jbe@267: end jbe@276: if args.anchor ~= nil and type(args.anchor) ~= "string" then jbe@267: error("Anchor passed to request.redirect{...} must be a string or nil.") jbe@267: end jbe@113: end jbe/bsw@0: if request.is_rerouted() then jbe/bsw@0: error("Tried to redirect after another forward or redirect.") jbe/bsw@0: end jbe@267: request._redirect = args jbe@267: if args.module and args.view then -- TODO: support for external redirects jbe@267: trace.redirect{ module = args.module, view = args.view } jbe@267: end jbe/bsw@0: end