Skip to content

Commit da1115f

Browse files
committed
feat: add basic type
1 parent e77e8a2 commit da1115f

24 files changed

+2515
-80
lines changed

api/api_impl/impl.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package apiimpl
2+
3+
import (
4+
"github.com/jiaozifs/jiaozifs/api"
5+
"github.com/jiaozifs/jiaozifs/controller"
6+
"go.uber.org/fx"
7+
)
8+
9+
var _ api.ServerInterface = (*APIController)(nil)
10+
11+
type APIController struct {
12+
fx.In
13+
14+
controller.VersionController
15+
controller.ObjectController
16+
}

api/custom_response.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ type JiaozifsResponse struct {
1010
}
1111

1212
func (response *JiaozifsResponse) RespJSON(v interface{}) {
13-
data, err := json.Marshal(v)
13+
response.Header().Set("Content-Type", "application/json")
14+
response.WriteHeader(http.StatusOK)
15+
err := json.NewEncoder(response).Encode(response)
1416
if err != nil {
1517
response.RespError(err)
1618
return
1719
}
18-
response.Header().Set("Content-Type", "application/json")
19-
response.WriteHeader(http.StatusOK)
20-
_, _ = response.Write(data)
2120
}
2221

2322
func (response *JiaozifsResponse) RespError(err error) {

0 commit comments

Comments
 (0)