example/

directory
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2024 License: MIT

README

Http代理服务模拟

  • 进入http_real_server目录,执行。
go run real_server.go
  • 在网址中输入127.0.0.1:8081/你设置的httpRule

Tcp代理服务模拟

  • 进入tcp_real_server目录,执行。
go run real_server.go
  • 新建窗口执行
telnet 127.0.0.1 你设置的代理端口

GRPC代理服务模拟

  • 进入grpc_real_server目录。
  • 进入server目录,启动服务端。
go run main.go
  • 进入client目录,在代码中设置好你的代理端口,然后启动客户端。
go run main.go

GRPC测试环境配置

https://github.com/grpc-ecosystem/grpc-gateway

  • 开启 go mod export GO111MODULE=on
  • 开启代理 go mod export GOPROXY=https://goproxy.io
  • 执行安装命令
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go install  github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go install github.com/golang/protobuf/protoc-gen-go

构建grpc-gateway 测试服务端

  • 编写 echo-gateway.proto
  • 运行IDL生成命令
protoc -I/usr/local/include -I. -I/root/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.16.0/third_party/googleapis --go_out=plugins=grpc:proto echo-gateway.proto
  • 运行gateway生成命令
protoc -I/usr/local/include -I. -I/root/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.16.0/third_party/googleapis --grpc-gateway_out=logtostderr=true:proto echo-gateway.proto

Directories

Path Synopsis
grpc_real_server
proto
Package proto is a reverse proxy.
Package proto is a reverse proxy.
server
Binary server is an example server.
Binary server is an example server.
模拟实际的下游节点
模拟实际的下游节点

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL