2
0

get.go 858 B

123456789101112131415161718192021222324252627282930
  1. package gitinstallation
  2. import (
  3. "net/http"
  4. "github.com/porter-dev/porter/api/server/handlers"
  5. "github.com/porter-dev/porter/api/server/shared"
  6. "github.com/porter-dev/porter/api/server/shared/config"
  7. "github.com/porter-dev/porter/api/types"
  8. "github.com/porter-dev/porter/internal/models/integrations"
  9. )
  10. type GitInstallationGetHandler struct {
  11. handlers.PorterHandlerWriter
  12. }
  13. func NewGitInstallationGetHandler(
  14. config *config.Config,
  15. writer shared.ResultWriter,
  16. ) *GitInstallationGetHandler {
  17. return &GitInstallationGetHandler{
  18. PorterHandlerWriter: handlers.NewDefaultPorterHandler(config, nil, writer),
  19. }
  20. }
  21. func (c *GitInstallationGetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  22. ga, _ := r.Context().Value(types.GitInstallationScope).(*integrations.GithubAppInstallation)
  23. c.WriteResult(w, r, ga.ToGitInstallationType())
  24. }