#[Actix Web] How to insert html in a existing html file and serve it?

2 messages · Page 1 of 1 (latest)

unique needle
#

So I am trying to implement ResponseError for my custom error object and I would like to make a default error.html page, and in their body or in some <div> I want to insert the error msg which i get from my_error.to_string(). What is the way to achieve this ?

impl ResponseError for NameErr {
    fn status_code(&self) -> actix_web::http::StatusCode {
        actix_web::http::StatusCode::BAD_REQUEST
    }

    fn error_response(&self) -> actix_web::HttpResponse {
        actix_web::HttpResponse::build(self.status_code())
            .insert_header(ContentType::html())
          // I WOULD LIKE TO SEND A FILE AS A HTML HERE AND THEN
          // RENDER THE ERROR MSG INTO IT
            .body(self.to_string())
    }
}
buoyant flax
#

i'll admit supporting this use case is a bit rough