Skip to content

Commit d5d38d2

Browse files
committed
update docs
1 parent a68af39 commit d5d38d2

File tree

7 files changed

+40
-17
lines changed

7 files changed

+40
-17
lines changed

.github/RELEASE.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
## New
22

3-
- Add generate cache code command and UI interface.
4-
- Convert swagger.json 64-bit fields type string to integer.
5-
- Uniform json name style for camel case.
6-
- Convert rpc code to http code.
7-
- Update documentation.
3+
- Passing metadata from the web service to the RPC service.
4+
- Delete json tag omitempty.
5+
- Add a project example.
6+
- Add a microservice cluster project example.

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,20 @@ Visit `http://localhost:24631` in your browser, generate code by manipulating it
8181

8282
### Examples of use
8383

84+
#### Basic Services example
85+
8486
- [1_web-gin-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/1_web-gin-CRUD)
8587
- [2_web-gin-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/2_web-gin-protobuf)
8688
- [3_micro-grpc-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/3_micro-grpc-CRUD)
8789
- [4_micro-grpc-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/4_micro-grpc-protobuf)
8890
- [5_micro-gin-rpc-gateway](https://github.com/zhufuyi/sponge_examples/tree/main/5_micro-gin-rpc-gateway)
8991
- [6_micro-cluster](https://github.com/zhufuyi/sponge_examples/tree/main/6_micro-cluster)
9092

93+
#### Full project example
94+
95+
- [7_community-single](https://github.com/zhufuyi/sponge_examples/tree/main/7_community-single)
96+
- [8_community-cluster](https://github.com/zhufuyi/sponge_examples/tree/main/8_community-cluster)
97+
9198
<br>
9299

93100
### Documentation

assets/readme-cn.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,19 @@ sponge run
6363

6464
### 使用示例
6565

66-
- [1_web-gin-CRUD](https://www.bilibili.com/read/cv23018269)
67-
- [2_web-gin-protobuf](https://www.bilibili.com/read/cv23040234)
68-
- [3_micro-grpc-CRUD](https://www.bilibili.com/read/cv23064432)
69-
- [4_micro-grpc-protobuf](https://www.bilibili.com/read/cv23099236)
70-
- [5_micro-gin-rpc-gateway](https://www.bilibili.com/read/cv23189890)
71-
- [6_micro-cluster](https://www.bilibili.com/read/cv23255594)
66+
#### 基础服务示例
67+
68+
- [1_web-gin-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/1_web-gin-CRUD)
69+
- [2_web-gin-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/2_web-gin-protobuf)
70+
- [3_micro-grpc-CRUD](https://github.com/zhufuyi/sponge_examples/tree/main/3_micro-grpc-CRUD)
71+
- [4_micro-grpc-protobuf](https://github.com/zhufuyi/sponge_examples/tree/main/4_micro-grpc-protobuf)
72+
- [5_micro-gin-rpc-gateway](https://github.com/zhufuyi/sponge_examples/tree/main/5_micro-gin-rpc-gateway)
73+
- [6_micro-cluster](https://github.com/zhufuyi/sponge_examples/tree/main/6_micro-cluster)
74+
75+
#### 完整项目示例
76+
77+
- [7_community-single](https://github.com/zhufuyi/sponge_examples/tree/main/7_community-single)
78+
- [8_community-cluster](https://github.com/zhufuyi/sponge_examples/tree/main/8_community-cluster)
7279

7380
<br>
7481

pkg/errcode/http_error.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func ParseError(err error) *Error {
9494
return Success
9595
}
9696

97-
unknownError := &Error{
97+
outError := &Error{
9898
code: -1,
9999
msg: "unknown error",
100100
}
@@ -103,12 +103,17 @@ func ParseError(err error) *Error {
103103
codeStr := strings.ReplaceAll(splits[0], "code = ", "")
104104
code, er := strconv.Atoi(codeStr)
105105
if er != nil {
106-
return unknownError
106+
return outError
107107
}
108108

109109
if e, ok := errCodes[code]; ok {
110+
if len(splits) > 1 {
111+
outError.code = code
112+
outError.msg = splits[1]
113+
return outError
114+
}
110115
return e
111116
}
112117

113-
return unknownError
118+
return outError
114119
}

pkg/errcode/http_error_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestNewError(t *testing.T) {
4343
Aborted,
4444
OutOfRange,
4545
Unimplemented,
46-
DataLoss,
46+
DataLoss.WithDetails("foo", "bar"),
4747
NewError(1010, "unknown"),
4848
}
4949

pkg/jwt/option.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func Init(opts ...Option) {
2828
var (
2929
defaultSigningKey = []byte("zaq12wsxmko0") // default key
3030
defaultSigningMethod = SigningMethodHS256 // default HS256
31-
defaultExpire = 2 * time.Hour // default expiration
31+
defaultExpire = 24 * time.Hour // default expiration
3232
defaultIssuer = ""
3333
)
3434

scripts/protoc.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ function generateBySpecifiedProto(){
109109

110110
checkResult $?
111111

112-
sponge web swagger --file=docs/apis.swagger.json
112+
# convert 64-bit fields type string to integer
113+
sponge web swagger --file=docs/apis.swagger.json > /dev/null
113114
checkResult $?
114115

115116
echo ""
@@ -138,6 +139,10 @@ generateBySpecifiedProto
138139
# delete unused packages in pb.go
139140
handlePbGoFiles $protoBasePath
140141

142+
# delete json tag omitempty
143+
sponge del-omitempty --dir=$protoBasePath --suffix-name=pb.go > /dev/null
144+
checkResult $?
145+
141146
go mod tidy
142147
checkResult $?
143148

0 commit comments

Comments
 (0)