Skip to content
Snippets Groups Projects
Commit 1b300ac7 authored by Sercan Yesildal's avatar Sercan Yesildal
Browse files

health service added

parent f4146cfb
No related branches found
No related tags found
No related merge requests found
module gitlab.reutlingen-university.de/yesildas/myaktion-go/src/myaktion module gitlab.reutlingen-university.de/yesildas/myaktion-go/src/myaktion
go 1.20 go 1.20
require github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
package handler
import (
"io"
"net/http"
)
func Health(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
io.WriteString(w, `{"alive": true}`)
}
package main package main
import "gitlab.reutlingen-university.de/yesildas/myaktion-go/src/myaktion/model" import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
"gitlab.reutlingen-university.de/yesildas/myaktion-go/src/myaktion/handler"
"gitlab.reutlingen-university.de/yesildas/myaktion-go/src/myaktion/model"
)
func main() { func main() {
campaign := model.Campaign{ campaign := model.Campaign{
...@@ -27,4 +35,12 @@ func main() { ...@@ -27,4 +35,12 @@ func main() {
}, },
Status: model.IN_PROCESS, Status: model.IN_PROCESS,
}) })
port := 8000
log.Printf("Starting MyAktion API server on port %v.\n", port)
router := mux.NewRouter()
router.HandleFunc("/health", handler.Health).Methods("GET")
if err := http.ListenAndServe(fmt.Sprintf(":%v", port), router); err != nil {
log.Fatal(err)
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment