capability_handler.go 637 B

12345678910111213141516171819202122232425262728
  1. package api
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. )
  6. // CapabilitiesExternal represents the Capabilities struct that will be sent over REST
  7. type CapabilitiesExternal struct {
  8. Provisioner bool `json:"provisioner"`
  9. GitHub bool `json:"github"`
  10. }
  11. // HandleGetCapabilities gets the capabilities of the server
  12. func (app *App) HandleGetCapabilities(w http.ResponseWriter, r *http.Request) {
  13. cap := app.CapConf
  14. capExternal := &CapabilitiesExternal{
  15. Provisioner: cap.Provisioner,
  16. GitHub: cap.Github,
  17. }
  18. if err := json.NewEncoder(w).Encode(capExternal); err != nil {
  19. app.handleErrorFormDecoding(err, ErrK8sDecode, w)
  20. return
  21. }
  22. }