摘要:
还是三步骤创建EndPoint,创建Transport,调用请求 第一步创建transport package Services import ( "context" "encoding/json" "errors" "github.com/tidwall/gjson" "io/ioutil" "net/http" ) func Deco... 阅读全文
摘要:
token设置过期时间 package main import ( "fmt" "github.com/dgrijalva/jwt-go" "io/ioutil" "log" "time" ) type UserClaim struct { Uname string `json:"username"` jwt.... 阅读全文
摘要:
生成公钥和私钥代码 package utils import ( "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/pem" "fmt" "io/ioutil" ) func GenRSAPubAndPri(bits int,filepath string ) error { //... 阅读全文
摘要:
使用第三方库jwt-go进行加密和验证 package main import ( "fmt" "github.com/dgrijalva/jwt-go" ) type UserClaim struct { Uname string `json:"username"` jwt.StandardClaims //嵌套了... 阅读全文
摘要:
使用中间件的方式包装日志输出 package Services import ( "context" "fmt" "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" "golang.org/x/time/rate" "gomicro/utils" "strconv" )... 阅读全文