/
match_service.go
43 lines (36 loc) · 998 Bytes
/
match_service.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
package rest
import (
"github.com/gnames/gnfmt"
"github.com/gnames/gnmatcher"
)
// matchMatcherREST implements MatcherService interface.
type matcherService struct {
gnmatcher.GNmatcher
port int
enc gnfmt.Encoder
}
// NewMNewMatcherREST is a constructor for MatchREST.
func NewMatcherService(gnm gnmatcher.GNmatcher,
port int, enc gnfmt.Encoder) MatcherService {
return matcherService{
GNmatcher: gnm,
port: port,
enc: enc,
}
}
// GetPort returns port number to the service.
func (mr matcherService) Port() int {
return mr.port
}
// Ping returns "pong" message if connection to the service did succed.
func (mr matcherService) Ping() string {
return "pong"
}
// Encode encodes an object into a byte slice.
func (mr matcherService) Encode(obj interface{}) ([]byte, error) {
return mr.enc.Encode(obj)
}
// Decode decodes an object from a bytes slice.
func (mr matcherService) Decode(input []byte, output interface{}) error {
return mr.enc.Decode(input, output)
}