In the first part we prepared ReactJS Application with SSR script that lets choose the best technologies for our Web Server.
Choosing Tech Stack for the SSR Web serverRust has the most powerful combination of safety and hight speed for today (you can check out here why – www.rust-lang.org ).
In addition, Actix-web framework is the fastest one according TechEmpower Framework BenchmarkSo, let’s use the best technologies for our forced Web Server.
We are ready for actually Web Server code now:HttpServer::new(|| { App::new() .wrap(middleware::Logger:: default ()) .service(Files::new( “/static” , “static” )) .default_service( web::resource( “” ) .route(web::get().to(index)) .route( web::route() .guard(guard::Not(guard::Get())) .to(|| HttpResponse::MethodNotAllowed()), ), ) }) .bind_rustls( “0.0.0.0:3001” , config)?
The function implements the routing logic, so our web server can return right HTML file (React server rendered) by a route.

Comments to: How To Improve React App Performance with SSR and Rust [Part II: Rust Web Server]

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

Login

Welcome to Typer

Brief and amiable onboarding is the first thing a new user sees in the theme.
Join Typer
Registration is closed.