fleet/server/service/endpoint_certificate.go
WangXiang 468754f2b9
Format and clean code (#774)
1. use [staticcheck](https://staticcheck.io/) to check the code, and fix some issues.
2. use `go fmt` to format the code.
3. use `go mod tidy` clean the go mod.
2021-05-17 10:29:50 -07:00

26 lines
637 B
Go

package service
import (
"context"
"github.com/fleetdm/fleet/server/kolide"
"github.com/go-kit/kit/endpoint"
)
type certificateResponse struct {
CertificateChain []byte `json:"certificate_chain"`
Err error `json:"error,omitempty"`
}
func (r certificateResponse) error() error { return r.Err }
func makeCertificateEndpoint(svc kolide.Service) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
chain, err := svc.CertificateChain(ctx)
if err != nil {
return certificateResponse{Err: err}, nil
}
return certificateResponse{CertificateChain: chain}, nil
}
}