|
|
@ -28,6 +28,28 @@ pub async fn index( req: HttpRequest ) -> Result { |
|
|
|
).await
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn rootwork( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
|
|
|
// if response Ok return HttpResponseBuilder
|
|
|
|
HttpResponse::Ok()
|
|
|
|
// set response content type html
|
|
|
|
.content_type("text/html")
|
|
|
|
// set response body to template context
|
|
|
|
.body(
|
|
|
|
// render template context
|
|
|
|
template::TplRootWork {
|
|
|
|
// lang to value of Accept-Language header
|
|
|
|
lang : &template::get_lang(&req),
|
|
|
|
}
|
|
|
|
// render template context into String
|
|
|
|
.render()
|
|
|
|
.map_err( |e| {
|
|
|
|
eprintln!("error_tplrender : {}", e );
|
|
|
|
error::crash( template::get_lang(&req), "error_tplrender" )
|
|
|
|
})?,
|
|
|
|
).await
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn hemp( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
|
|
|
// if response Ok return HttpResponseBuilder
|
|
|
|
HttpResponse::Ok()
|
|
|
@ -158,6 +180,50 @@ pub async fn robot( req: HttpRequest ) -> Result { |
|
|
|
).await
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn app( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
|
|
|
// if response Ok return HttpResponseBuilder
|
|
|
|
HttpResponse::Ok()
|
|
|
|
// set response content type html
|
|
|
|
.content_type("text/html")
|
|
|
|
// set response body to template context
|
|
|
|
.body(
|
|
|
|
// render template context
|
|
|
|
template::TplApp {
|
|
|
|
// lang to value of Accept-Language header
|
|
|
|
lang : &template::get_lang(&req),
|
|
|
|
}
|
|
|
|
|
|
|
|
// render template context into String
|
|
|
|
.render()
|
|
|
|
.map_err( |e| {
|
|
|
|
eprintln!("error_tplrender : {}", e );
|
|
|
|
error::crash( template::get_lang(&req), "error_tplrender" )
|
|
|
|
})?,
|
|
|
|
).await
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn business( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
|
|
|
// if response Ok return HttpResponseBuilder
|
|
|
|
HttpResponse::Ok()
|
|
|
|
// set response content type html
|
|
|
|
.content_type("text/html")
|
|
|
|
// set response body to template context
|
|
|
|
.body(
|
|
|
|
// render template context
|
|
|
|
template::TplModel {
|
|
|
|
// lang to value of Accept-Language header
|
|
|
|
lang : &template::get_lang(&req),
|
|
|
|
}
|
|
|
|
|
|
|
|
// render template context into String
|
|
|
|
.render()
|
|
|
|
.map_err( |e| {
|
|
|
|
eprintln!("error_tplrender : {}", e );
|
|
|
|
error::crash( template::get_lang(&req), "error_tplrender" )
|
|
|
|
})?,
|
|
|
|
).await
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|