code: func TaskContainerMetadataHandler(state dockerstate.TaskEngineState, ecsClient api.ECSClient, cluster, az, containerInstanceArn string, propagateTags bool) func(http.ResponseWriter, *http.Request) {
  	return func(w http.ResponseWriter, r *http.Request) {
  		taskARN, err := getTaskARNByRequest(r, state)
  		if err != nil {
  			responseJSON, _ := json.Marshal(
  				fmt.Sprintf("Unable to get task arn from request: %s", err.Error()))
  			utils.WriteJSONToResponse(w, http.StatusBadRequest, responseJSON, utils.RequestTypeTaskMetadata)
  			return
  		}
  		if containerID, ok := utils.GetMuxValueFromRequest(r, metadataContainerIDMuxName); ok {
  			seelog.Infof("V2 task/container metadata handler: writing response for container '%s'", containerID)
  			WriteContainerMetadataResponse(w, containerID, state)
  			return
  		}
  
  		seelog.Infof("V2 task/container metadata handler: writing response for task '%s'", taskARN)
  		WriteTaskMetadataResponse(w, taskARN, cluster, state, ecsClient, az, containerInstanceArn, propagateTags)
  	}
  }
docs: // TaskContainerMetadataHandler returns the handler method for handling task and container metadata requests.