Skip to content

Commit

Permalink
Add a Go httpserver for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jessedearing committed Jan 25, 2024
1 parent c85d4b6 commit c62c6ca
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
FROM docker.io/library/golang:1 AS http-server
WORKDIR /app
COPY go-httpserver .
RUN go build .

FROM docker.io/library/archlinux:latest
ENV KAFKA_VERSION=3.6.1
RUN curl -L https://www.archlinux.org/mirrorlist/\?country\=US\&protocol=http\&protocol\=https\&ip_version\=4 | sed -e 's/^#Server/Server/' -e '/^#/d' | tee /etc/pacman.d/mirrorlist && \
Expand All @@ -11,6 +16,7 @@ RUN curl -L https://www.archlinux.org/mirrorlist/\?country\=US\&protocol=http\&p
rm -rf /var/cache/pacman/*

COPY tools/check-clock-skew.sh /usr/local/bin/check-clock-skew.sh
COPY --from=http-server /app/go-httpserver /usr/local/bin/go-httpserver
COPY etc/profile.d/set-vi.sh /etc/profile.d/set-vi.sh

ENV SHELL=/usr/bin/zsh
Expand Down
1 change: 1 addition & 0 deletions go-httpserver/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go-httpserver
8 changes: 8 additions & 0 deletions go-httpserver/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module go.jesse.dev/go-httpserver

go 1.17

require (
github.com/sirupsen/logrus v1.8.1 // indirect
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
)
7 changes: 7 additions & 0 deletions go-httpserver/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
30 changes: 30 additions & 0 deletions go-httpserver/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"
"net/http"
"net/http/httputil"

"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)

func main() {
hs := http.Server{
Addr: ":8080",
}

mux := http.NewServeMux()
hs.Handler = mux
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
bs, err := httputil.DumpRequest(req, false)
if err != nil {
logrus.Error(err)
return
}
fmt.Println(string(bs))
w.WriteHeader(http.StatusOK)
w.Write([]byte("👋 Hello🏻"))
})
log.Error(hs.ListenAndServe())
}

0 comments on commit c62c6ca

Please sign in to comment.