api

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2025 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	APIEndpointPushCert = "/pushcert"
	APIEndpointPush     = "/push/"    // note trailing slash
	APIEndpointEnqueue  = "/enqueue/" // note trailing slash
)

Variables

This section is empty.

Functions

func HandleAPIv1 added in v0.8.0

func HandleAPIv1(prefix string, mux Mux, logger log.Logger, store APIStorage, pusher push.Pusher)

HandleAPIv1 registers the various API handlers into mux. API endpoint paths are prepended with prefix. Authentication or any other layered handlers are not present. They are assumed to be layered with mux. If prefix is empty and these handlers are used in sub-paths then handlers should have that sub-path stripped from the request. The logger is adorned with a "handler" key of the endpoint name.

func PathIDGetter added in v0.8.0

func PathIDGetter(r *http.Request) ([]string, error)

PathIDGetter returns the list of comma-separated enrollment IDs from r.

func PushHandler deprecated

func PushHandler(pusher push.Pusher, logger log.Logger) http.HandlerFunc

PushHandler sends APNs push notifications to MDM enrollments.

Note the whole URL path is used as the identifier to push to. This probably necessitates stripping the URL prefix before using. Also note we expose Go errors to the output as this is meant for "API" users.

Deprecated: use PushToIDsHandler instead. Use PathIDGetter with it for the previous behavior.

func PushToIDsHandler added in v0.8.0

func PushToIDsHandler(pusher push.Pusher, logger log.Logger, idGetter func(*http.Request) ([]string, error)) http.HandlerFunc

PushToIDsHandler sends APNs push notifications to MDM enrollments. Use idGetter to get the slice of enrollment IDs from the HTTP request.

func RawCommandEnqueueHandler deprecated

func RawCommandEnqueueHandler(enqueuer storage.CommandEnqueuer, pusher push.Pusher, logger log.Logger) http.HandlerFunc

RawCommandEnqueueHandler enqueues a raw MDM command plist and sends push notifications to MDM enrollments.

Note the whole URL path is used as the identifier to enqueue (and push to. This probably necessitates stripping the URL prefix before using. Also note we expose Go errors to the output as this is meant for "API" users.

Deprecated: use RawCommandEnqueueToIDsHandler instead. Use PathIDGetter with it for the previous behavior.

func RawCommandEnqueueToIDsHandler added in v0.8.0

func RawCommandEnqueueToIDsHandler(enqueuer storage.CommandEnqueuer, pusher push.Pusher, logger log.Logger, idGetter func(*http.Request) ([]string, error)) http.HandlerFunc

RawCommandEnqueueToIDsHandler enqueues a raw MDM command and sends push notifications to MDM enrollments. Use idGetter to get the slice of enrollment IDs from the HTTP request.

func StorePushCertHandler

func StorePushCertHandler(storage storage.PushCertStore, logger log.Logger) http.HandlerFunc

StorePushCertHandler reads a PEM-encoded certificate and private key from the HTTP body and saves it to storage. This effectively enables us to do something like: "% cat push.pem push.key | curl -T - http://api.example.com/" to upload our push certs.

Types

type APIStorage added in v0.8.0

type APIStorage interface {
	storage.PushCertStore
	storage.CommandEnqueuer
}

APIStorage is required for the API handlers.

type Mux added in v0.8.0

type Mux interface {
	// Handle registers the handler for the given pattern.
	// It is assumed pattern operates similar to http.ServeMux with
	// respect to "trailing slash" behavior.
	Handle(pattern string, handler http.Handler)
}

Mux can register HTTP handlers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL