-
Notifications
You must be signed in to change notification settings - Fork 9
/
endpoint.go
32 lines (26 loc) · 903 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
package export
import (
"context"
"github.com/go-kit/kit/endpoint"
)
// Endpoints wraps a service behind a set of endpoints.
type Endpoints struct {
Endpoint endpoint.Endpoint
}
// Component is the user component interface.
type Component interface {
Export(ctx context.Context) (map[string]interface{}, error)
StoreAndExport(ctx context.Context) (map[string]interface{}, error)
}
// MakeExportEndpoint makes endpoint that reads the config in DB.
func MakeExportEndpoint(c Component) endpoint.Endpoint {
return func(ctx context.Context, _ interface{}) (interface{}, error) {
return c.Export(ctx)
}
}
// MakeStoreAndExportEndpoint makes the endpoint that forces the keycloak exportation and stores the config in DB.
func MakeStoreAndExportEndpoint(c Component) endpoint.Endpoint {
return func(ctx context.Context, _ interface{}) (interface{}, error) {
return c.StoreAndExport(ctx)
}
}