-
-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathendpoints.go
105 lines (94 loc) · 2.77 KB
/
endpoints.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Code generated by goa v3.15.2, DO NOT EDIT.
//
// tools endpoints
//
// Command:
// $ goa gen github.com/arduino/arduino-create-agent/design
package tools
import (
"context"
goa "goa.design/goa/v3/pkg"
)
// Endpoints wraps the "tools" service endpoints.
type Endpoints struct {
Available goa.Endpoint
Installedhead goa.Endpoint
Installed goa.Endpoint
Install goa.Endpoint
Remove goa.Endpoint
}
// NewEndpoints wraps the methods of the "tools" service with endpoints.
func NewEndpoints(s Service) *Endpoints {
return &Endpoints{
Available: NewAvailableEndpoint(s),
Installedhead: NewInstalledheadEndpoint(s),
Installed: NewInstalledEndpoint(s),
Install: NewInstallEndpoint(s),
Remove: NewRemoveEndpoint(s),
}
}
// Use applies the given middleware to all the "tools" service endpoints.
func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) {
e.Available = m(e.Available)
e.Installedhead = m(e.Installedhead)
e.Installed = m(e.Installed)
e.Install = m(e.Install)
e.Remove = m(e.Remove)
}
// NewAvailableEndpoint returns an endpoint function that calls the method
// "available" of service "tools".
func NewAvailableEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) {
res, err := s.Available(ctx)
if err != nil {
return nil, err
}
vres := NewViewedToolCollection(res, "default")
return vres, nil
}
}
// NewInstalledheadEndpoint returns an endpoint function that calls the method
// "installedhead" of service "tools".
func NewInstalledheadEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) {
return nil, s.Installedhead(ctx)
}
}
// NewInstalledEndpoint returns an endpoint function that calls the method
// "installed" of service "tools".
func NewInstalledEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) {
res, err := s.Installed(ctx)
if err != nil {
return nil, err
}
vres := NewViewedToolCollection(res, "default")
return vres, nil
}
}
// NewInstallEndpoint returns an endpoint function that calls the method
// "install" of service "tools".
func NewInstallEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) {
p := req.(*ToolPayload)
res, err := s.Install(ctx, p)
if err != nil {
return nil, err
}
vres := NewViewedOperation(res, "default")
return vres, nil
}
}
// NewRemoveEndpoint returns an endpoint function that calls the method
// "remove" of service "tools".
func NewRemoveEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) {
p := req.(*ToolPayload)
res, err := s.Remove(ctx, p)
if err != nil {
return nil, err
}
vres := NewViewedOperation(res, "default")
return vres, nil
}
}