1
0
mirror of https://github.com/go-kratos/kratos.git synced 2026-05-22 10:15:24 +02:00

feat(transport): add transport tls config (#1267)

* add http tls config

* add grpc tls config

* add examples tls

* fix resolver parseTarget

* support https for discovery

* add isSecure
* clean code

Co-authored-by: longXboy <longxboyhi@gmail.com>
Co-authored-by: 包子 <baozhecheng@foxmail.com>
This commit is contained in:
Tony Chen
2021-07-28 13:36:15 +08:00
committed by GitHub
parent ce0cba4f41
commit 5ca42fe921
14 changed files with 379 additions and 16 deletions
+2
View File
@@ -27,6 +27,7 @@ func callHTTP() {
if err != nil {
panic(err)
}
defer conn.Close()
client := pb.NewGreeterHTTPClient(conn)
reply, err := client.SayHello(context.Background(), &pb.HelloRequest{Name: "kratos"})
if err != nil {
@@ -55,6 +56,7 @@ func callGRPC() {
if err != nil {
panic(err)
}
defer conn.Close()
client := pb.NewGreeterClient(conn)
reply, err := client.SayHello(context.Background(), &pb.HelloRequest{Name: "kratos"})
if err != nil {
+6 -6
View File
@@ -39,18 +39,18 @@ func (s *server) SayHello(ctx context.Context, in *helloworld.HelloRequest) (*he
func main() {
s := &server{}
grpcSrv := grpc.NewServer(
grpc.Address(":9000"),
grpc.Middleware(
recovery.Recovery(),
),
)
httpSrv := http.NewServer(
http.Address(":8000"),
http.Middleware(
recovery.Recovery(),
),
)
grpcSrv := grpc.NewServer(
grpc.Address(":9000"),
grpc.Middleware(
recovery.Recovery(),
),
)
helloworld.RegisterGreeterServer(grpcSrv, s)
helloworld.RegisterGreeterHTTPServer(httpSrv, s)