func (e *Endpoint) CreateWorkload(w http.ResponseWriter, r *http.Request) {
	requestID := r.Header.Get("x-request-id")
	if requestID == "" {
		respondPlainText(w, http.StatusBadRequest, "error: missing x-request-id key in request header")
		return
	}
	apiName := r.Header.Get(consts.CortexAPINameHeader)
	if requestID == "" {
		respondPlainText(w, http.StatusBadRequest, fmt.Sprintf("error: missing %s key in request header", consts.CortexAPINameHeader))
		return
	}
	r.Header.Del(consts.CortexAPINameHeader)
	queueURL := r.Header.Get(consts.CortexQueueURLHeader)
	if queueURL == "" {
		respondPlainText(w, http.StatusBadRequest, fmt.Sprintf("error: missing %s key in request header", consts.CortexQueueURLHeader))
		return
	}
	r.Header.Del(consts.CortexQueueURLHeader)
	body := r.Body
	defer func() {
		_ = r.Body.Close()
	}()
	log := e.logger.With(zap.String("id", requestID), zap.String("apiName", apiName))
	id, err := e.service.CreateWorkload(requestID, apiName, queueURL, body, r.Header)
	if err != nil {
		respondPlainText(w, http.StatusInternalServerError, fmt.Sprintf("error: %v", err))
		logErrorWithTelemetry(log, errors.Wrap(err, "failed to create workload"))
		return
	}
	if err = respondJSON(w, http.StatusOK, CreateWorkloadResponse{ID: id}); err != nil {
		logErrorWithTelemetry(log, errors.Wrap(err, "failed to encode json response"))
		return
	}
}
CreateWorkload is a handler for the async-gateway service workload creation route
package gateway
import (
	"encoding/json"
	"fmt"
	"net/http"
	"github.com/cortexlabs/cortex/pkg/consts"
	"github.com/cortexlabs/cortex/pkg/lib/errors"
	"github.com/cortexlabs/cortex/pkg/lib/telemetry"
	"github.com/cortexlabs/cortex/pkg/types/async"
	"github.com/gorilla/mux"
	"go.uber.org/zap"
)
type Endpoint struct {
	service Service
	logger  *zap.SugaredLogger
}
func NewEndpoint(svc Service, logger *zap.SugaredLogger) *Endpoint {
	return &Endpoint{
		service: svc,
		logger:  logger,
	}
}