mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-13 05:45:41 +08:00
28 lines
636 B
Go
28 lines
636 B
Go
package management
|
|
|
|
import (
|
|
"github.com/go-kit/kit/endpoint"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
type pushRequest struct {
|
|
UDID string
|
|
}
|
|
|
|
type pushResponse struct {
|
|
Status string `json:"status,omitempty"`
|
|
ID string `json:"push_notification_id,omitempty"`
|
|
Err error `json:"error,omitempty"`
|
|
}
|
|
|
|
func makePushEndpoint(svc Service) endpoint.Endpoint {
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
req := request.(pushRequest)
|
|
id, err := svc.Push(req.UDID)
|
|
if err != nil {
|
|
return pushResponse{Err: err, Status: "failure"}, nil
|
|
}
|
|
return pushResponse{Status: "success", ID: id}, nil
|
|
}
|
|
}
|