岚天逸见

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 79 下一页

2023年12月15日 #

go-zero开发入门之gateway深入研究1

摘要: 创建一个 gateway 示例: // main.go package main import ( "flag" "fmt" "gateway/middleware" "github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go- 阅读全文

posted @ 2023-12-15 17:58 岚天逸见 阅读(372) 评论(0) 推荐(0)

go-zero目录结构和说明

摘要: . ├── code-of-conduct.md 行为准则 ├── CONTRIBUTING.md 贡献指南 ├── core 框架的核心组件 │ ├── bloom 布隆过滤器,用于检测一个元素是否在一个集合中 │ ├── breaker 熔断器,用于防止过多的请求导致系统崩溃 │ ├── cmd 阅读全文

posted @ 2023-12-15 10:06 岚天逸见 阅读(320) 评论(0) 推荐(0)

2023年12月13日 #

go-zero开发入门之网关往rpc服务传递数据2

摘要: go-zero 的网关服务实际是个 go-zero 的 API 服务,也就是一个 http 服务,或者说 rest 服务。http 转 grpc 使用了开源的 grpcurl 库,当网关需要往 rpc 服务传递额外的数据,比如鉴权数据的时候,通过 http 的 header 进行: func Aut 阅读全文

posted @ 2023-12-13 21:49 岚天逸见 阅读(420) 评论(0) 推荐(0)

2023年12月12日 #

go-zero开发入门之网关往rpc服务传递数据1

摘要: go-zero 的网关往 rpc 服务传递数据时,可以使用 headers,但需要注意前缀规则,否则会发现数据传递不过去,或者对方取不到数据。 go-zero 的网关对服务的调用使用了第三方库 grpcurl,入口函数为 InvokeRPC: grpcurl.InvokeRPC(r.Context( 阅读全文

posted @ 2023-12-12 18:59 岚天逸见 阅读(332) 评论(0) 推荐(0)

2023年12月10日 #

go-zero开发入门-API网关鉴权开发示例

摘要: 本文是go-zero开发入门-API网关开发示例一文的延伸,继续之前请先阅读此文。 在项目根目录下创建子目录 middleware,在此目录下创建文件 auth.go,内容如下: // 鉴权中间件 package middleware import ( "context" "errors" "net 阅读全文

posted @ 2023-12-10 20:18 岚天逸见 阅读(484) 评论(0) 推荐(0)

2023年12月8日 #

go-zero开发入门-API服务开发示例

摘要: 接口定义 定义 API 接口文件 接口文件 add.api 的内容如下: syntax = "v1" info ( title: "API 接口文件示例" desc: "演示如何编写 API 接口文件" author: "一见" date: "2023年12月07日" version: "v1" ) 阅读全文

posted @ 2023-12-08 11:03 岚天逸见 阅读(277) 评论(0) 推荐(0)

go-zero开发入门-API网关开发示例

摘要: 开发一个 API 网关,代理 https://www.cnblogs.com/aquester/p/17882070.html 中的 RPC 服务。 网关完整源代码 // file: main.go package main import ( "flag" "fmt" "github.com/zer 阅读全文

posted @ 2023-12-08 10:13 岚天逸见 阅读(662) 评论(0) 推荐(0)

2023年12月7日 #

go-zero的etcd配置

摘要: 实现代码在 core/discov/config.go 文件中: type EtcdConf struct { Hosts []string Key string ID int64 `json:",optional"` User string `json:",optional"` Pass stri 阅读全文

posted @ 2023-12-07 17:55 岚天逸见 阅读(277) 评论(0) 推荐(0)

“go mod tidy”之错误“not a valid zip file”

摘要: 执行 go mod tidy 时,遇到如下错误: rpc imports github.com/zeromicro/go-zero/zrpc imports github.com/zeromicro/go-zero/zrpc/resolver imports github.com/zeromicro 阅读全文

posted @ 2023-12-07 17:28 岚天逸见 阅读(852) 评论(0) 推荐(0)

go-zero开发入门-加法客服端示例

摘要: 定义 RPC 接口文件 接口文件 add.proto 的内容如下: syntax = "proto3"; package add; // 当 protoc-gen-go 版本大于 1.4.0 时需加上 go_package,否则编译报错“unable to determine Go import p 阅读全文

posted @ 2023-12-07 15:14 岚天逸见 阅读(249) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 79 下一页

导航