-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.go
41 lines (31 loc) · 850 Bytes
/
map.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
package http
import (
"context"
"github.com/alexfalkowski/bezeichner/server/ids"
"github.com/alexfalkowski/go-service/meta"
)
type (
// MapIdentifiersRequest for some identifiers.
MapIdentifiersRequest struct {
IDs []string `json:"ids,omitempty"`
}
// MapIdentifiersResponse for some identifiers.
MapIdentifiersResponse struct {
Meta map[string]string `json:"meta,omitempty"`
IDs []string `json:"ids,omitempty"`
}
mapHandler struct {
service *ids.Identifier
}
)
func (h *mapHandler) Map(ctx context.Context, req *MapIdentifiersRequest) (*MapIdentifiersResponse, error) {
resp := &MapIdentifiersResponse{}
ids, err := h.service.Map(req.IDs)
if err != nil {
resp.Meta = meta.CamelStrings(ctx, "")
return resp, handleError(err)
}
resp.IDs = ids
resp.Meta = meta.CamelStrings(ctx, "")
return resp, nil
}