github.com/freiheit-com/kuberpult@v1.24.2-0.20240328135542-315d5630abe6/services/cd-service/pkg/service/service.go (about)

     1  /*This file is part of kuberpult.
     2  
     3  Kuberpult is free software: you can redistribute it and/or modify
     4  it under the terms of the Expat(MIT) License as published by
     5  the Free Software Foundation.
     6  
     7  Kuberpult is distributed in the hope that it will be useful,
     8  but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    10  MIT License for more details.
    11  
    12  You should have received a copy of the MIT License
    13  along with kuberpult. If not, see <https://directory.fsf.org/wiki/License:Expat>.
    14  
    15  Copyright 2023 freiheit.com*/
    16  
    17  package service
    18  
    19  import (
    20  	"fmt"
    21  	"net/http"
    22  
    23  	xpath "github.com/freiheit-com/kuberpult/pkg/path"
    24  	"github.com/freiheit-com/kuberpult/services/cd-service/pkg/repository"
    25  )
    26  
    27  type Service struct {
    28  	Repository repository.Repository
    29  }
    30  
    31  func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    32  	head, _ := xpath.Shift(r.URL.Path)
    33  	switch head {
    34  	case "health":
    35  		s.ServeHTTPHealth(w, r)
    36  	case "release":
    37  		w.WriteHeader(http.StatusNotFound)
    38  		fmt.Fprintf(w, "release endpoint is now only provided in the frontend-service")
    39  	}
    40  }
    41  
    42  func (s *Service) ServeHTTPHealth(w http.ResponseWriter, r *http.Request) {
    43  	w.WriteHeader(http.StatusOK)
    44  	fmt.Fprintf(w, "ok\n")
    45  }
    46  
    47  var _ http.Handler = (*Service)(nil)