1.添加gzip引用

1
use actix_web::middleware::Compress;

2.接口开启gzip压缩

1
2
3
4
5
6
       App::new().service(scope("/api/v1/swagger")
            .wrap(middleware::Logger::default())
            .wrap(logging_middleware::Logging)
            .wrap(Compress::default())
            .configure(user_routes).route("/{value}", web::get().to(index))
    });

3.gzip压缩验证

image