158 Star 1.8K Fork 359

GVPkevwan/go-zero

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github
core
gateway
internal
config.go
readme.md
server.go
server_test.go
internal
rest
tools/goctl
zrpc
.codecov.yml
.dockerignore
.gitattributes
.gitignore
CONTRIBUTING.md
LICENSE
code-of-conduct.md
go.mod
go.sum
readme-cn.md
readme.md
克隆/下载
readme.md 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
kevwan 提交于 3年前 . Update readme.md

Gateway

Usage

  • main.go
var configFile = flag.String("f", "config.yaml", "config file")

func main() {
    flag.Parse()

    var c gateway.GatewayConf
    conf.MustLoad(*configFile, &c)
    gw := gateway.MustNewServer(c)
    defer gw.Stop()
    gw.Start()
}
  • config.yaml
Name: demo-gateway
Host: localhost
Port: 8888
Upstreams:
  - Grpc:
      Etcd:
        Hosts:
          - localhost:2379
        Key: hello.rpc
    # protoset mode
    ProtoSets:
      - hello.pb
    # Mappings can also be written in proto options
    Mappings:
      - Method: get
        Path: /pingHello/:ping
        RpcPath: hello.Hello/Ping
  - Grpc:
      Endpoints:
        - localhost:8081
    # reflection mode, no ProtoSet settings
    Mappings:
      - Method: post
        Path: /pingWorld
        RpcPath: world.World/Ping

Generate ProtoSet files

  • example command without external imports
protoc --descriptor_set_out=hello.pb hello.proto
  • example command with external imports
protoc --include_imports --proto_path=. --descriptor_set_out=hello.pb hello.proto
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kevwan/go-zero.git
git@gitee.com:kevwan/go-zero.git
kevwan
go-zero
go-zero
master

搜索帮助