Status codes and plain text responses
These two are used during server-side rendering, they do nothing in the browser.
HTTP status code
By default the server responds with status 200. To respond with another code, call set_status while rendering, for example when the route is not found:
use vertigo::{dom, get_driver, router::Router}; let router = Router::<String>::new_history_router(); router.route.render_value(|path| match path.as_str() { "/" => dom! { <main>"Home"</main> }, _ => { // Ignored in the browser get_driver().set_status(404); dom! { <main>"Page not found"</main> } } })
Plain text responses
Some URLs, like /robots.txt, should return plain text instead of the app. Register a handler for them with plains, while starting the app:
// Inside the function marked with #[main] use vertigo::{dom, get_driver}; get_driver().plains(|url| match url { "/robots.txt" => Some("User-agent: *\nDisallow: /admin/\n".to_string()), "/health" => Some("OK".to_string()), // Render the app as usual _ => None, }); dom! { <html> <head /> <body>"Hello!"</body> </html> }
When the handler returns Some, the server responds with this text and text/plain content type. For None the app is rendered as usual.