mirror of
https://github.com/Walter-Sparrow/lunar-tear.git
synced 2026-07-02 13:53:41 +03:00
26 lines
601 B
Go
26 lines
601 B
Go
package interceptor
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"lunar-tear/server/internal/gametime"
|
|
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/metadata"
|
|
)
|
|
|
|
func TimeSync(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
|
resp, err := handler(ctx, req)
|
|
switch info.FullMethod {
|
|
case "/apb.api.user.UserService/Auth",
|
|
"/apb.api.user.UserService/RegisterUser",
|
|
"/apb.api.user.UserService/TransferUser":
|
|
default:
|
|
grpc.SetTrailer(ctx, metadata.Pairs(
|
|
"x-apb-response-datetime", fmt.Sprintf("%d", gametime.NowMillis()),
|
|
))
|
|
}
|
|
return resp, err
|
|
}
|