Files
micromdm/platform/apns/server.go
Victor Vrantchan 70d26149ae only register HTTP routes once (#418)
Simplified the registration of HTTP routes.
Moved basic auth middleware to use the provided go-kit library.
2018-05-12 19:17:40 -04:00

39 lines
1.0 KiB
Go

package apns
import (
"github.com/go-kit/kit/endpoint"
httptransport "github.com/go-kit/kit/transport/http"
"github.com/gorilla/mux"
"github.com/micromdm/micromdm/pkg/httputil"
)
type Endpoints struct {
PushEndpoint endpoint.Endpoint
}
func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints {
return Endpoints{
PushEndpoint: endpoint.Chain(outer, others...)(MakePushEndpoint(s)),
}
}
func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) {
// GET /push/:udid create an APNS Push notification for a managed device or user(deprecated)
// POST /v1/push/:udid create an APNS Push notification for a managed device or user
r.Methods("GET").Path("/push/{udid}").Handler(httptransport.NewServer(
e.PushEndpoint,
decodePushRequest,
httputil.EncodeJSONResponse,
options...,
))
r.Methods("POST").Path("/v1/push/{udid}").Handler(httptransport.NewServer(
e.PushEndpoint,
decodePushRequest,
httputil.EncodeJSONResponse,
options...,
))
}