Skip to content
Snippets Groups Projects
Unverified Commit 02bf97e2 authored by Will McCutchen's avatar Will McCutchen Committed by GitHub
Browse files

Merge pull request #7 from mccutchen/makefile

Various small fixes
parents 793a5046 445f7f23
No related branches found
No related tags found
No related merge requests found
--- ---
language: go language: go
go: go:
- 1.8 - '1.8'
- tip - '1.9'
script: make test - '1.10'
before_install: - '1.11'
- go get -u github.com/jteeuwen/go-bindata/... - 'tip'
script:
- make lint
- make test
notifications: notifications:
email: false email: false
FROM golang:1.9 FROM golang:1.11
RUN go get -u github.com/jteeuwen/go-bindata/...
WORKDIR /go/src/github.com/mccutchen/go-httpbin WORKDIR /go/src/github.com/mccutchen/go-httpbin
COPY Makefile .
RUN make deps
COPY . . COPY . .
RUN make RUN make
......
commit := $(shell git rev-parse --short HEAD) .PHONY: clean deps image imagepush run test testcover
COMMIT := $(shell git rev-parse --short HEAD)
GENERATED_ASSETS_PATH := httpbin/assets/assets.go
BIN_DIR := $(GOPATH)/bin
GOLINT := $(BIN_DIR)/golint
GOBINDATA := $(BIN_DIR)/go-bindata
TEST_ARGS := -race
build: dist/go-httpbin build: dist/go-httpbin
dist/go-httpbin: assets cmd/go-httpbin/*.go httpbin/*.go dist/go-httpbin: $(GENERATED_ASSETS_PATH) cmd/go-httpbin/*.go httpbin/*.go
mkdir -p dist mkdir -p dist
go build -o dist/go-httpbin ./cmd/go-httpbin go build -o dist/go-httpbin ./cmd/go-httpbin
assets: httpbin/assets/* $(GENERATED_ASSETS_PATH): $(GOBINDATA) static/*
go-bindata -o httpbin/assets/assets.go -pkg=assets -prefix=static static $(GOBINDATA) -o $(GENERATED_ASSETS_PATH) -pkg=assets -prefix=static static
# reformat generated code
gofmt -s -w $(GENERATED_ASSETS_PATH)
# dumb hack to make generate code lint correctly
sed -i.bak 's/Html/HTML/g' $(GENERATED_ASSETS_PATH)
sed -i.bak 's/Xml/XML/g' $(GENERATED_ASSETS_PATH)
rm $(GENERATED_ASSETS_PATH).bak
test: assets test:
go test ./... go test $(TEST_ARGS) ./...
testcover: assets testcover:
mkdir -p dist mkdir -p dist
go test -coverprofile=dist/coverage.out github.com/mccutchen/go-httpbin/httpbin go test $(TEST_ARGS) -coverprofile=dist/coverage.out github.com/mccutchen/go-httpbin/httpbin
go tool cover -html=dist/coverage.out go tool cover -html=dist/coverage.out
lint: $(GOLINT)
test -z "$$(gofmt -d -s -e .)" || (gofmt -d -s -e . ; exit 1)
$(GOLINT) -set_exit_status ./...
go vet ./...
run: build run: build
./dist/go-httpbin ./dist/go-httpbin
clean: clean:
rm -r dist rm -r dist
deps: image: $(GENERATED_ASSETS_PATH) cmd/go-httpbin/*.go httpbin/*.go
go get -u github.com/jteeuwen/go-bindata/... docker build -t mccutchen/go-httpbin:$(COMMIT) .
image: assets cmd/go-httpbin/*.go httpbin/*.go
mkdir -p /tmp/go-httpbin-docker
cp Dockerfile /tmp/go-httpbin-docker
GOOS=linux GOARCH=amd64 go build -o /tmp/go-httpbin-docker/go-httpbin ./cmd/go-httpbin
docker build -t mccutchen/go-httpbin:$(commit) /tmp/go-httpbin-docker
imagepush: image imagepush: image
docker push mccutchen/go-httpbin:$(commit) docker push mccutchen/go-httpbin:$(COMMIT)
assets: $(GENERATED_ASSETS_PATH)
deps: $(GOLINT) $(GOBINDATA)
$(GOLINT):
go get -u golang.org/x/lint/golint
$(GOBINDATA):
go get -u github.com/kevinburke/go-bindata/...
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -178,29 +178,29 @@ func (h *HTTPBin) Status(w http.ResponseWriter, r *http.Request) { ...@@ -178,29 +178,29 @@ func (h *HTTPBin) Status(w http.ResponseWriter, r *http.Request) {
303: redirectHeaders, 303: redirectHeaders,
305: redirectHeaders, 305: redirectHeaders,
307: redirectHeaders, 307: redirectHeaders,
401: &statusCase{ 401: {
headers: map[string]string{ headers: map[string]string{
"WWW-Authenticate": `Basic realm="Fake Realm"`, "WWW-Authenticate": `Basic realm="Fake Realm"`,
}, },
}, },
402: &statusCase{ 402: {
body: []byte("Fuck you, pay me!"), body: []byte("Fuck you, pay me!"),
headers: map[string]string{ headers: map[string]string{
"X-More-Info": "http://vimeo.com/22053820", "X-More-Info": "http://vimeo.com/22053820",
}, },
}, },
406: &statusCase{ 406: {
body: notAcceptableBody, body: notAcceptableBody,
headers: map[string]string{ headers: map[string]string{
"Content-Type": jsonContentType, "Content-Type": jsonContentType,
}, },
}, },
407: &statusCase{ 407: {
headers: map[string]string{ headers: map[string]string{
"Proxy-Authenticate": `Basic realm="Fake Realm"`, "Proxy-Authenticate": `Basic realm="Fake Realm"`,
}, },
}, },
418: &statusCase{ 418: {
body: []byte("I'm a teapot!"), body: []byte("I'm a teapot!"),
headers: map[string]string{ headers: map[string]string{
"X-More-Info": "http://tools.ietf.org/html/rfc2324", "X-More-Info": "http://tools.ietf.org/html/rfc2324",
......
...@@ -181,13 +181,6 @@ Content-Length: 135 ...@@ -181,13 +181,6 @@ Content-Length: 135
</code></pre> </code></pre>
<h2 id="Changelog">Changelog</h2>
<ul>
<li>0.1.0: Initial port</li>
</ul>
<h2 id="AUTHOR">AUTHOR</h2> <h2 id="AUTHOR">AUTHOR</h2>
<p>Ported to Go by <a href="https://github.com/mccutchen">Will McCutchen</a>.</p> <p>Ported to Go by <a href="https://github.com/mccutchen">Will McCutchen</a>.</p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment