Skip to content

Commit c62c6ca

Browse files
committed
Add a Go httpserver for debugging
1 parent c85d4b6 commit c62c6ca

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
FROM docker.io/library/golang:1 AS http-server
2+
WORKDIR /app
3+
COPY go-httpserver .
4+
RUN go build .
5+
16
FROM docker.io/library/archlinux:latest
27
ENV KAFKA_VERSION=3.6.1
38
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 && \
@@ -11,6 +16,7 @@ RUN curl -L https://www.archlinux.org/mirrorlist/\?country\=US\&protocol=http\&p
1116
rm -rf /var/cache/pacman/*
1217

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

1622
ENV SHELL=/usr/bin/zsh

go-httpserver/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go-httpserver

go-httpserver/go.mod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module go.jesse.dev/go-httpserver
2+
3+
go 1.17
4+
5+
require (
6+
github.com/sirupsen/logrus v1.8.1 // indirect
7+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
8+
)

go-httpserver/go.sum

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3+
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
4+
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
5+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
6+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
7+
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

go-httpserver/main.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"net/http/httputil"
7+
8+
"github.com/sirupsen/logrus"
9+
log "github.com/sirupsen/logrus"
10+
)
11+
12+
func main() {
13+
hs := http.Server{
14+
Addr: ":8080",
15+
}
16+
17+
mux := http.NewServeMux()
18+
hs.Handler = mux
19+
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
20+
bs, err := httputil.DumpRequest(req, false)
21+
if err != nil {
22+
logrus.Error(err)
23+
return
24+
}
25+
fmt.Println(string(bs))
26+
w.WriteHeader(http.StatusOK)
27+
w.Write([]byte("👋 Hello🏻"))
28+
})
29+
log.Error(hs.ListenAndServe())
30+
}

0 commit comments

Comments
 (0)