func (s *Server) HandleDeleteService() http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		defer utils.CloseTheCloser(r.Body)
		ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
		defer cancel()
		_, err := s.auth.VerifyToken(utils.GetToken(r))
		if err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to apply service", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusUnauthorized, err)
			return
		}
		vars := mux.Vars(r)
		projectID := vars["project"]
		serviceID := vars["serviceId"]
		version := vars["version"]
		if err := s.driver.DeleteService(ctx, projectID, serviceID, version); err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to apply service", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusInternalServerError, err)
			return
		}
		_ = helpers.Response.SendOkayResponse(ctx, http.StatusOK, w)
	}
}
HandleDeleteService handles the request to delete a service
package server
import (
	"bufio"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"time"
	"github.com/gorilla/mux"
	"github.com/spaceuptech/helpers"
	"github.com/spaceuptech/space-cloud/runner/model"
	"github.com/spaceuptech/space-cloud/runner/utils"
)
func (s *Server) handleCreateProject() http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		defer utils.CloseTheCloser(r.Body)
		ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
		defer cancel()
		_, err := s.auth.VerifyToken(utils.GetToken(r))
		if err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to create project", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusUnauthorized, err)
			return
		}
		vars := mux.Vars(r)
		projectID := vars["project"]
		project := new(model.Project)
		if err := json.NewDecoder(r.Body).Decode(project); err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to create project", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusBadRequest, err)
			return
		}
		project.ID = projectID
		if err := s.driver.CreateProject(ctx, project); err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to create project", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusInternalServerError, err)
			return
		}
		_ = helpers.Response.SendOkayResponse(ctx, http.StatusOK, w)
	}
}
func (s *Server) handleDeleteProject() http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		defer utils.CloseTheCloser(r.Body)
		ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
		defer cancel()
		_, err := s.auth.VerifyToken(utils.GetToken(r))
		if err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to create project", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusUnauthorized, err)
			return
		}
		vars := mux.Vars(r)
		projectID := vars["project"]
		if err := s.driver.DeleteProject(ctx, projectID); err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to create project", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusInternalServerError, err)
			return
		}
		_ = helpers.Response.SendOkayResponse(ctx, http.StatusOK, w)
	}
}
func (s *Server) handleApplyService() http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		defer utils.CloseTheCloser(r.Body)
		ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
		defer cancel()
		_, err := s.auth.VerifyToken(utils.GetToken(r))
		if err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to apply service", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusUnauthorized, err)
			return
		}
		vars := mux.Vars(r)
		projectID := vars["project"]
		serviceID := vars["serviceId"]
		version := vars["version"]
		service := new(model.Service)
		if err := json.NewDecoder(r.Body).Decode(service); err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to apply service", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusBadRequest, err)
			return
		}
		service.ProjectID = projectID
		service.ID = serviceID
		service.Version = version
		if err := s.driver.ApplyService(ctx, service); err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), "Failed to apply service", err, nil)
			_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusInternalServerError, err)
			return
		}
		_ = helpers.Response.SendOkayResponse(ctx, http.StatusOK, w)
	}
}
func (s *Server) handleGetLogs() http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		defer utils.CloseTheCloser(r.Body)
		vars := mux.Vars(r)
		projectID := vars["project"]
		req, err := generateLogRequestFromQueryParams(r.Context(), r.URL)
		if err != nil {
			_ = helpers.Response.SendErrorResponse(r.Context(), w, http.StatusInternalServerError, err)
			return
		}
		helpers.Logger.LogDebug(helpers.GetRequestID(context.TODO()), "Get logs process started", map[string]interface{}{"projectId": projectID, "taskId": req.TaskID, "replicaId": req.ReplicaID, "isFollow": req.IsFollow, "tail": req.Tail})
		pipeReader, err := s.driver.GetLogs(r.Context(), projectID, req)
		if err != nil {
			_ = helpers.Logger.LogError(helpers.GetRequestID(context.TODO()), "Failed to get service logs", err, nil)
			_ = helpers.Response.SendErrorResponse(r.Context(), w, http.StatusInternalServerError, err)
			return
		}
		defer utils.CloseTheCloser(pipeReader)
		reader := bufio.NewReader(pipeReader)
		flusher, ok := w.(http.Flusher)
		if !ok {
			_ = helpers.Response.SendErrorResponse(r.Context(), w, http.StatusBadRequest, fmt.Errorf("expected http.ResponseWriter to be an http.Flusher"))
			return
		}
		w.Header().Set("X-Content-Type-Options", "nosniff")
		w.WriteHeader(http.StatusOK)
		for {
			select {
			case <-r.Context().Done():
				helpers.Logger.LogDebug(helpers.GetRequestID(context.TODO()), "Context deadline reached for client request", map[string]interface{}{})
				return
			default:
				str, err := reader.ReadString('\n')
				if err != nil {
					if err == io.EOF && !req.IsFollow {
						helpers.Logger.LogDebug(helpers.GetRequestID(context.TODO()), "End of file reached for logs", map[string]interface{}{})
						return
					}
					helpers.Logger.LogDebug(helpers.GetRequestID(context.TODO()), "error occured while reading from pipe in hander", nil)
					_ = helpers.Response.SendErrorResponse(r.Context(), w, http.StatusInternalServerError, err)
					return
				}
				fmt.Fprint(w, str)
				flusher.Flush()
			}
		}
	}
}