capability_handler.go 669 B

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