refactor command service to use one method per file (#416)

Updated the command service to have the same structure as all the other services within platform/...
This commit is contained in:
Victor Vrantchan
2018-05-12 17:04:05 -04:00
committed by GitHub
parent a6681610e3
commit c1c1cfb175
8 changed files with 117 additions and 332 deletions

View File

@@ -0,0 +1,34 @@
package command
import (
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/log"
httptransport "github.com/go-kit/kit/transport/http"
"github.com/gorilla/mux"
"github.com/micromdm/micromdm/pkg/httputil"
)
type Endpoints struct {
NewCommandEndpoint endpoint.Endpoint
}
func MakeServerEndpoints(s Service) Endpoints {
return Endpoints{
NewCommandEndpoint: MakeNewCommandEndpoint(s),
}
}
func MakeHTTPHandler(e Endpoints, logger log.Logger) *mux.Router {
r, options := httputil.NewRouter(logger)
// POST /v1/commands Add new MDM Command to device queue.
r.Methods("POST").Path("/v1/commands").Handler(httptransport.NewServer(
e.NewCommandEndpoint,
decodeNewCommandRequest,
httputil.EncodeJSONResponse,
options...,
))
return r
}