forked from CyCoreSystems/ari-proxy
/
endpoint.go
57 lines (47 loc) · 1.11 KB
/
endpoint.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
51
52
53
54
55
56
57
package server
import (
"context"
"github.com/CyCoreSystems/ari-proxy/proxy"
)
func (s *Server) endpointData(ctx context.Context, reply string, req *proxy.Request) {
data, err := s.ari.Endpoint().Data(req.Key)
if err != nil {
s.sendError(reply, err)
return
}
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Endpoint: data,
},
})
}
func (s *Server) endpointGet(ctx context.Context, reply string, req *proxy.Request) {
data, err := s.ari.Endpoint().Data(req.Key)
if err != nil {
s.sendError(reply, err)
return
}
s.publish(reply, &proxy.Response{
Key: data.Key,
})
}
func (s *Server) endpointList(ctx context.Context, reply string, req *proxy.Request) {
list, err := s.ari.Endpoint().List(nil)
if err != nil {
s.sendError(reply, err)
return
}
s.publish(reply, &proxy.Response{
Keys: list,
})
}
func (s *Server) endpointListByTech(ctx context.Context, reply string, req *proxy.Request) {
list, err := s.ari.Endpoint().ListByTech(req.EndpointListByTech.Tech, req.Key)
if err != nil {
s.sendError(reply, err)
return
}
s.publish(reply, &proxy.Response{
Keys: list,
})
}