code: func TaskContainerStatsHandler(state dockerstate.TaskEngineState, statsEngine stats.Engine) func(http.ResponseWriter, *http.Request) {
  	return func(w http.ResponseWriter, r *http.Request) {
  		taskARN, err := getTaskARNByRequest(r, state)
  		if err != nil {
  			errResponseJSON, _ := json.Marshal(
  				fmt.Sprintf("Unable to get task arn from request: %s", err.Error()))
  			utils.WriteJSONToResponse(w, http.StatusBadRequest, errResponseJSON, utils.RequestTypeTaskStats)
  			return
  		}
  		if containerID, ok := utils.GetMuxValueFromRequest(r, statsContainerIDMuxName); ok {
  			seelog.Infof("V2 task/container stats handler: writing response for container '%s'", containerID)
  			WriteContainerStatsResponse(w, taskARN, containerID, statsEngine)
  			return
  		}
  
  		seelog.Infof("V2 task/container stats handler: writing response for task '%s'", taskARN)
  		WriteTaskStatsResponse(w, taskARN, state, statsEngine)
  	}
  }
docs: // TaskContainerStatsHandler returns the handler method for handling task and container stats requests.