You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: preflight_check.go
    path of file: ./repos/porter/api/server/handlers/project_integration
    
    the code of the file until where you have to start completion: package project_integration

import (
	"net/http"

	"connectrpc.com/connect"
	"github.com/porter-dev/api-contracts/generated/go/helpers"
	porterv1 "github.com/porter-dev/api-contracts/generated/go/porter/v1"
	"github.com/porter-dev/porter/api/server/handlers"
	"github.com/porter-dev/porter/api/server/shared"
	"github.com/porter-dev/porter/api/server/shared/apierrors"
	"github.com/porter-dev/porter/api/server/shared/config"
	"github.com/porter-dev/porter/api/types"
	"github.com/porter-dev/porter/internal/models"
	"github.com/porter-dev/porter/internal/telemetry"
)

// Create
    
func (p *CreatePreflightCheckHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	ctx, span := telemetry.NewSpan(r.Context(), "preflight-checks")
	defer span.End()
	project, _ := ctx.Value(types.ProjectScope).(*models.Project)

	cloudValues := &porterv1.PreflightCheckRequest{}
	err := helpers.UnmarshalContractObjectFromReader(r.Body, cloudValues)
	if err != nil {
		e := telemetry.Error(ctx, span, err, "error unmarshalling preflight check data")
		p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(e, http.StatusPreconditionFailed, err.Error()))
		return
	}

	var resp PreflightCheckResponse

	input := porterv1.PreflightCheckRequest{
		ProjectId:                  int64(project.ID),
		CloudProvider:              cloudValues.CloudProvider,
		CloudProviderCredentialsId: cloudValues.CloudProviderCredentialsId,
		Contract:                   cloudValues.Contract,
	}

	if cloudValues.PreflightValues != nil {
		if cloudValues.CloudProvider == porterv1.EnumCloudProvider_ENUM_CLOUD_PROVIDER_GCP || cloudValues.CloudProvider == porterv1.EnumCloudProvider_ENUM_CLOUD_PROVIDER_AWS {
			input.PreflightValues = cloudValues.PreflightValues
		}
	}

	checkResp, err := p.Config().ClusterControlPlaneClient.PreflightCheck(ctx, connect.NewRequest(&input))
	if err != nil {
		err = telemetry.Error(ctx, span, err, "error calling preflight checks")
		p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
		return
	}

	if checkResp.Msg == nil {
		err = telemetry.Error(ctx, span, nil, "no message received from preflight checks")
		p.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusInternalServerError))
		return
	}

	errors := []PreflightCheckError{}
	for key, val := range checkResp.Msg.PreflightChecks {
		if val.Message == "" || !contains(recognizedPreflightCheckKeys, key) {
			continue
		}

		errors = append(errors, PreflightCheckError{
			Name: key,
			Error: PorterError{
				Code:     val.Code,
				Message:  val.Message,
				Metadata: val.Metadata,
			},
		})
	}
	resp.Errors = errors
	p.WriteResult(w, r, resp)
}