(server) chore: Modify Server (#31)

This commit is contained in:
2025-07-14 17:19:30 +08:00
parent 2efd018094
commit e35236b8ef
3 changed files with 23 additions and 0 deletions

19
Server/Cargo.lock generated
View File

@ -850,6 +850,7 @@ dependencies = [
"tokio",
"tonic",
"tonic-build",
"tonic-web",
]
[[package]]
@ -1017,6 +1018,24 @@ dependencies = [
"syn",
]
[[package]]
name = "tonic-web"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774cad0f35370f81b6c59e3a1f5d0c3188bdb4a2a1b8b7f0921c860bfbd3aec6"
dependencies = [
"base64",
"bytes",
"http",
"http-body",
"pin-project",
"tokio-stream",
"tonic",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tower"
version = "0.5.2"

View File

@ -12,6 +12,7 @@ log = "0.4"
prost = "0.13"
tokio = { version = "1", features = ["full"] }
tonic = "0.13"
tonic-web = "0.13"
[build-dependencies]
tonic-build = "0.13"

View File

@ -2,6 +2,7 @@ use std::net::SocketAddr;
use tonic::transport::Server;
use tonic::{Request, Response, Status};
use tonic_web::GrpcWebLayer;
use crate::protocol::game_service_server::{GameService, GameServiceServer};
use crate::protocol::general_service_server::{GeneralService, GeneralServiceServer};
@ -19,6 +20,8 @@ impl GrpcServer {
let game_service = GameServiceServer::new(GameServiceImpl);
Server::builder()
.accept_http1(true)
.layer(GrpcWebLayer::new())
.add_service(general_service)
.add_service(game_service)
.serve(addr)