first push - trying to get live debug going.

This commit is contained in:
Erik Eckert 2023-12-04 08:37:53 -07:00
parent 83e673b69f
commit cb81c7fd63
6 changed files with 85 additions and 0 deletions

21
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,21 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Go Debug - Local",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${file}",
"args": []
},
{
"name": "Go Debug - Docker",
"type": "go",
"request": "attach",
"mode": "remote",
"port": 4000,
"host": "127.0.0.1"
}
]
}

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM golang:alpine
WORKDIR /app
EXPOSE 80
COPY main.go ./
ENV GO111MODULE=off
RUN go build -o hello-app .
CMD [ "./hello-app" ]

11
Dockerfile.debug Normal file
View File

@ -0,0 +1,11 @@
FROM golang:alpine
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
ENV GO111MODULE=off
RUN CGO_ENABLED=0 go build -gcflags "all=-N -l" -o debug-app .
CMD [ "/go/bin/dlv", "--listen=:4000", "--headless=true", "--log=true", "--accept-multiclient", "--api-version=2", "exec", "/app/debug-app" ]

5
main/go.mod Normal file
View File

@ -0,0 +1,5 @@
module git.mpe.ca/eeckert/egnytewebhandler
go 1.21.4
require github.com/gorilla/mux v1.8.1 // indirect

2
main/go.sum Normal file
View File

@ -0,0 +1,2 @@
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=

37
main/main.go Normal file
View File

@ -0,0 +1,37 @@
package main
import (
"fmt"
"io"
"log"
"net/http"
"github.com/gorilla/mux"
)
func readDataStream(resp http.ResponseWriter, request *http.Request) {
reqBody, _ := io.ReadAll(request.Body)
// var jsonBody = json.NewDecoder(request.Body)
fmt.Println(reqBody)
}
func HealthCheck() {
}
func handleRequests() {
// Start new Mux router
mainrouter := mux.NewRouter().StrictSlash(true)
mainrouter.HandleFunc("/", readDataStream).Methods("POST")
// mainrouter.HandleFunc("/healthcheck", HealthCheck).Methods("GET")
log.Fatal(http.ListenAndServe(":10000", mainrouter))
}
func main() {
fmt.Println("MPE x Egnyte x PowerApps - Mux Router")
handleRequests()
}