上一页 1 2 3 4 5 6 7 8 ··· 22 下一页
摘要: 当服务很简单的时候可以用这种方法来做基本调用 package main import ( "fmt" "github.com/micro/go-micro/client/selector" "github.com/micro/go-micro/registry" "github.com/micro/ 阅读全文
posted @ 2019-12-26 14:49 离地最远的星 阅读(587) 评论(0) 推荐(0) 编辑
摘要: 看下面的代码调用了server.Init()之后就支持命令行读取配置了 package main import ( "github.com/gin-gonic/gin" "github.com/micro/go-micro/registry" "github.com/micro/go-micro/w 阅读全文
posted @ 2019-12-25 16:23 离地最远的星 阅读(558) 评论(0) 推荐(0) 编辑
摘要: 我们会使用主站api调用商品api 使用go-micro访问consul获取服务信息 package main import ( "fmt" "github.com/micro/go-micro/client/selector" "github.com/micro/go-micro/registry 阅读全文
posted @ 2019-12-25 16:09 离地最远的星 阅读(2616) 评论(0) 推荐(0) 编辑
摘要: 安装go-plugins go get -v github.com/micro/go-plugins,原来go-micro consul的支持已经迁移到了go-plugins里面 package main import ( "github.com/gin-gonic/gin" "github.com 阅读全文
posted @ 2019-12-25 15:52 离地最远的星 阅读(1498) 评论(0) 推荐(0) 编辑
摘要: package main import ( "github.com/gin-gonic/gin" "github.com/micro/go-micro/web" ) func main() { ginRouter := gin.Default() ginRouter.Handle("GET", "/ 阅读全文
posted @ 2019-12-25 15:08 离地最远的星 阅读(627) 评论(0) 推荐(0) 编辑
摘要: 先下载Go Micro框架 go get -v github.com/micro/go-micro 启动一个简单的Server package main import ( "github.com/micro/go-micro/web" "net/http" ) func main() { /*第一种 阅读全文
posted @ 2019-12-25 14:55 离地最远的星 阅读(403) 评论(0) 推荐(0) 编辑
摘要: 还是三步骤创建EndPoint,创建Transport,调用请求 第一步创建transport package Services import ( "context" "encoding/json" "errors" "github.com/tidwall/gjson" "io/ioutil" "net/http" ) func Deco... 阅读全文
posted @ 2019-12-24 15:24 离地最远的星 阅读(910) 评论(1) 推荐(0) 编辑
摘要: token设置过期时间 package main import ( "fmt" "github.com/dgrijalva/jwt-go" "io/ioutil" "log" "time" ) type UserClaim struct { Uname string `json:"username"` jwt.... 阅读全文
posted @ 2019-12-24 13:36 离地最远的星 阅读(6460) 评论(0) 推荐(0) 编辑
摘要: 生成公钥和私钥代码 package utils import ( "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/pem" "fmt" "io/ioutil" ) func GenRSAPubAndPri(bits int,filepath string ) error { //... 阅读全文
posted @ 2019-12-24 12:09 离地最远的星 阅读(3872) 评论(0) 推荐(0) 编辑
摘要: 使用第三方库jwt-go进行加密和验证 package main import ( "fmt" "github.com/dgrijalva/jwt-go" ) type UserClaim struct { Uname string `json:"username"` jwt.StandardClaims //嵌套了... 阅读全文
posted @ 2019-12-24 11:28 离地最远的星 阅读(695) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 22 下一页