I am trying to replace the catch-all 404 in Actix-Web with a redirect (307) to a constant URL.
Currently I've implemented it via a handler registered to a default service:
async fn redirector() -> HttpResponse {
HttpResponse::build(StatusCode::TEMPORARY_REDIRECT).append_header((header::LOCATION, "https://tracker.mywaifu.best")).finish()
}
(Commit: Redirect to mywaifu homepage · ckcr4lyf/kiryuu@00d91b5 · GitHub)
But I'm guessing on every missed route now it is constructing this new response, allocating the header memory etc.
Since the redirect I want to return is static, is it possible to somehow do this more efficiently?