I need a Server Action step to render a view (EJS file):
// Example in Laravel
return view('maintenance_page', ['name' => 'James']);
Purpose:
The website has a maintenance mode. If the user attempts to load a certain other page, it should be presented with an HTTP status code 503 and the maintenance view rendered. Redirects (HTTP status code 302) are not allowed to preserve SEO.
The check if the website is under maintenance mode is run under Globals, where it has a chance to run steps like Response, that override all further steps and standard view loading.
It would be nice if it could run the associated server-side action attached to the view, but not necessary if able to pass variables to the view during the call.
i admit not knowing the best approach to this. but i wonder how many times will the query in Globals get executed if we do it like that. why not instead have global parameter to Boolean maintenance mode working with db and the scheduler on main layout and not on admin layout?
Having a maintenance flag in DB allows you to toggle it without server restart or new docker image because you can't dynamical change global variables.
If we talking about "natural" Wappler approach of course.
A redirect with status code 503 is not possible (as far as I know), hence this feature request
It would be executed at every page and every server connect. The database software might cache the query but I wouldn't count on that. Linux caches file reads so I think a file is the best solution, and in fact that's how it's implemented in e.g. Laravel.
i don't think it is a good thing to use a value that might be cached and could get stale as the flag for maintenance mode. it must be trigger sensitive. i look forward for a provision in this regard by Wappler team that can work around the issues we have.
Instead of having to implement logic on all your pages you can better create a custom middleware that checks if server is in maintenance mode and show that page before any other route.