added writin the file

This commit is contained in:
Valentyn Faychuk 2024-09-02 14:25:51 +03:00
parent c2d1274cac
commit b03ca1cfc6
Signed by: valy
GPG Key ID: F1AB995E20FEADC5

@ -8,6 +8,7 @@ use hyper_util::{
service::TowerToHyperService, service::TowerToHyperService,
}; };
use pb::{EchoRequest, EchoResponse}; use pb::{EchoRequest, EchoResponse};
use std::io::Write;
use std::sync::Arc; use std::sync::Arc;
use tokio::net::TcpListener; use tokio::net::TcpListener;
use tokio_rustls::{ use tokio_rustls::{
@ -37,6 +38,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{}", e)))?; .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{}", e)))?;
tls.alpn_protocols = vec![b"h2".to_vec()]; tls.alpn_protocols = vec![b"h2".to_vec()];
// create and write a file on the disk
let mut file = std::fs::File::create("test.txt")?;
file.write_all(b"Hello, world!")?;
let server = EchoServer::default(); let server = EchoServer::default();
let svc = Routes::new(pb::echo_server::EchoServer::new(server)).prepare(); let svc = Routes::new(pb::echo_server::EchoServer::new(server)).prepare();