Files
matchbox/api/ignition.go
Dalton Hubble bb976840e1 Documentation: Add group matcher docs, improve docs and examples
* Remove Machine docs since machine resources are no longer used
2016-01-08 12:12:48 -08:00

27 lines
580 B
Go

package api
import (
"net/http"
)
// ignitionHandler returns a handler that responds with the ignition config
// for the requester.
func ignitionHandler(store Store) http.Handler {
fn := func(w http.ResponseWriter, req *http.Request) {
attrs := labelsFromRequest(req)
spec, err := getMatchingSpec(store, attrs)
if err != nil || spec.IgnitionConfig == "" {
http.NotFound(w, req)
return
}
config, err := store.IgnitionConfig(spec.IgnitionConfig)
if err != nil {
http.NotFound(w, req)
return
}
renderJSON(w, config)
}
return http.HandlerFunc(fn)
}