First of all I have tried to click on index.html that served from Actix, it is very fast ever. ... I implement Web Server by GoFiber to serve static files, I use the following code:
package main
import (
"log"
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New()
app.Static("/", "./public")
log.Fatal(app.Listen(":8000"))
}
It works properly.
Then I try to implement a Web Server by Rust in Actix, I use the following code:
use actix_files as fs;
use actix_web::{App, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new().service(
fs::Files::new("/", "./public")
.show_files_listing()
.use_last_modified(true),
)
})
.bind("0.0.0.0:8000")?
.run()
.await
}
It shows as the following image:
How can I change Actix code to serve the whole html files from gatsby deploy automatically like GoFiber? When I click index.html, it works very well and I feel that it blazingly fast more than any other Web Server Platform that I have used.
Maybe I’m wrong in asking questions. I can find the solution:
use actix_files as fs;
use actix_web::{App, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new().service(
fs::Files::new("/", "./public")
.show_files_listing()
.index_file("index.html")
.use_last_modified(true),
)
})
.bind("0.0.0.0:8000")?
.run()
.await
}