forked from go-kit/kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
endpoint.go
34 lines (27 loc) · 945 Bytes
/
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
package handling
import (
"time"
"golang.org/x/net/context"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/examples/shipping/cargo"
"github.com/go-kit/kit/examples/shipping/location"
"github.com/go-kit/kit/examples/shipping/voyage"
)
type registerIncidentRequest struct {
ID cargo.TrackingID
Location location.UNLocode
Voyage voyage.Number
EventType cargo.HandlingEventType
CompletionTime time.Time
}
type registerIncidentResponse struct {
Err error `json:"error,omitempty"`
}
func (r registerIncidentResponse) error() error { return r.Err }
func makeRegisterIncidentEndpoint(hs Service) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
req := request.(registerIncidentRequest)
err := hs.RegisterHandlingEvent(req.CompletionTime, req.ID, req.Voyage, req.Location, req.EventType)
return registerIncidentResponse{Err: err}, nil
}
}