update git - moving to devdontainer

This commit is contained in:
Erik Eckert 2023-12-04 15:03:40 -07:00
parent cb81c7fd63
commit c2b5c15bb9
5 changed files with 21 additions and 7 deletions

2
.vscode/launch.json vendored
View File

@ -5,7 +5,7 @@
"name": "Go Debug - Local",
"type": "go",
"request": "launch",
"mode": "auto",
"mode": "debug",
"program": "${file}",
"args": []
},

View File

@ -1,10 +1,12 @@
FROM golang:alpine
RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest
# RUN CGO_ENABLED=0 go get -d github.com/gorilla/mux@latest
WORKDIR /app
EXPOSE 80 4000
COPY ./main/* ./
RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest
RUN go install github.com/gorilla/mux
RUN go install github.com/gorilla/mux
ENV GO111MODULE=off
RUN CGO_ENABLED=0 go build -gcflags "all=-N -l" -o debug-app .

View File

@ -2,4 +2,7 @@ module git.mpe.ca/eeckert/egnytewebhandler
go 1.21.4
require github.com/gorilla/mux v1.8.1 // indirect
require (
github.com/gorilla/mux v1.8.1
golang.org/x/text v0.14.0
)

View File

@ -1,2 +1,4 @@
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=

View File

@ -5,6 +5,7 @@ import (
"io"
"log"
"net/http"
"time"
"github.com/gorilla/mux"
)
@ -13,11 +14,17 @@ func readDataStream(resp http.ResponseWriter, request *http.Request) {
reqBody, _ := io.ReadAll(request.Body)
// var jsonBody = json.NewDecoder(request.Body)
fmt.Println(reqBody)
fmt.Println(string(reqBody))
}
func HealthCheck() {
func HealthCheck(resp http.ResponseWriter, request *http.Request) {
var t = time.Now().String()
var MessageText = t + ": Health Check from " + request.RemoteAddr
// reqBody, _ := io.ReadAll(request.Body)
fmt.Println(http.StatusOK, MessageText)
resp.WriteHeader(http.StatusOK)
resp.Write([]byte(MessageText))
}
func handleRequests() {
@ -25,7 +32,7 @@ func handleRequests() {
mainrouter := mux.NewRouter().StrictSlash(true)
mainrouter.HandleFunc("/", readDataStream).Methods("POST")
// mainrouter.HandleFunc("/healthcheck", HealthCheck).Methods("GET")
mainrouter.HandleFunc("/healthcheck", HealthCheck).Methods("GET")
log.Fatal(http.ListenAndServe(":10000", mainrouter))