forked from sharat87/httpbun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
34 lines (26 loc) · 949 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
LDFLAGS := -ldflags "-X github.com/sharat87/httpbun/info.Commit=$$(git rev-parse HEAD) -X github.com/sharat87/httpbun/info.Date=$$(date -u +%Y-%m-%dT%H:%M:%SZ)"
run:
go mod tidy
go fmt ./...
go run $(LDFLAGS) main.go
build:
make patch
@go build $(LDFLAGS) -v -o bin/httpbun
make unpatch
docker:
make patch
CGO_ENABLED=0 GOOS=linux go build $(LDFLAGS) -a -installsuffix cgo -o bin/httpbun-docker .
make unpatch
docker build -t httpbun .
test:
@go test -count=1 -vet=all ./...
fmt:
@go fmt ./...
# We patch the Go stdlib to remove the code that removes the Host header from incoming requests.
patch:
sed 's:\(delete(req.Header, "Host")\)$$://\1:' "$$(go env GOROOT)/src/net/http/server.go" > x
mv x "$$(go env GOROOT)/src/net/http/server.go"
unpatch:
sed 's://\(delete(req.Header, "Host")\)$$:\1:' "$$(go env GOROOT)/src/net/http/server.go" > x
mv x "$$(go env GOROOT)/src/net/http/server.go"
.PHONY: run build docker test fmt