/
rpc_adapter.go
50 lines (42 loc) · 1.08 KB
/
rpc_adapter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package controller
import (
"github.com/glvd/accipfs/core"
"net/http"
)
// JSONRPCAdapter //todo
type JSONRPCAdapter interface {
ID(r *http.Request, req *core.IDReq, resp *core.IDResp) error
Add(r *http.Request, req *core.AddReq, resp *core.AddResp) error
Get(r *http.Request, req *core.GetReq, resp *core.GetResp) error
Pay(r *http.Request, req *core.PayReq, resp *core.PayResp) error
}
type adapter struct {
api core.API
controller *Controller
}
// ID ...
func (a adapter) ID(r *http.Request, req *core.IDReq, resp *core.IDResp) error {
id, err := a.api.ID(r.Context(), req)
if err != nil {
return err
}
resp = id
return nil
}
// Add ...
func (a adapter) Add(r *http.Request, req *core.AddReq, resp *core.AddResp) error {
panic("implement me")
}
// Get ...
func (a adapter) Get(r *http.Request, req *core.GetReq, resp *core.GetResp) error {
panic("implement me")
}
// Pay ...
func (a adapter) Pay(r *http.Request, req *core.PayReq, resp *core.PayResp) error {
panic("implement me")
}
func newAdapter(api core.API) JSONRPCAdapter {
return &adapter{
api: api,
}
}