зеркало из https://github.com/mozilla/doorman.git
Rename handlers to api
This commit is contained in:
Родитель
2db17712e2
Коммит
f47a59c98a
|
@ -1,5 +1,5 @@
|
|||
main
|
||||
handlers/bindata.go
|
||||
api/bindata.go
|
||||
coverage.txt
|
||||
policies.yaml
|
||||
vendor/
|
||||
|
|
22
Makefile
22
Makefile
|
@ -2,15 +2,15 @@ GO_LINT := $(GOPATH)/bin/golint
|
|||
GO_DEP := $(GOPATH)/bin/dep
|
||||
GO_BINDATA := $(GOPATH)/bin/go-bindata
|
||||
GO_PACKAGE := $(GOPATH)/src/github.com/mozilla/doorman
|
||||
DATA_FILES := ./handlers/openapi.yaml ./handlers/contribute.yaml
|
||||
SRC := *.go ./config/*.go ./handlers/*.go ./authn/*.go ./doorman/*.go
|
||||
PACKAGES := ./ ./config/ ./handlers/ ./authn/ ./doorman/
|
||||
DATA_FILES := ./api/openapi.yaml ./api/contribute.yaml
|
||||
SRC := *.go ./config/*.go ./api/*.go ./authn/*.go ./doorman/*.go
|
||||
PACKAGES := ./ ./config/ ./api/ ./authn/ ./doorman/
|
||||
|
||||
main: vendor handlers/bindata.go $(SRC) $(GO_PACKAGE)
|
||||
main: vendor api/bindata.go $(SRC) $(GO_PACKAGE)
|
||||
CGO_ENABLED=0 go build -o main *.go
|
||||
|
||||
clean:
|
||||
rm -f main coverage.txt handlers/bindata.go vendor
|
||||
rm -f main coverage.txt api/bindata.go vendor
|
||||
|
||||
$(GOPATH):
|
||||
mkdir -p $(GOPATH)
|
||||
|
@ -28,8 +28,8 @@ $(GO_BINDATA): $(GOPATH)
|
|||
vendor: $(GO_DEP) Gopkg.lock Gopkg.toml
|
||||
$(GO_DEP) ensure
|
||||
|
||||
handlers/bindata.go: $(GO_BINDATA) $(DATA_FILES)
|
||||
$(GO_BINDATA) -o handlers/bindata.go -pkg handlers $(DATA_FILES)
|
||||
api/bindata.go: $(GO_BINDATA) $(DATA_FILES)
|
||||
$(GO_BINDATA) -o api/bindata.go -pkg api $(DATA_FILES)
|
||||
|
||||
policies.yaml:
|
||||
touch policies.yaml
|
||||
|
@ -47,10 +47,10 @@ lint: $(GO_LINT)
|
|||
fmt:
|
||||
gofmt -w -s $(SRC)
|
||||
|
||||
test: vendor policies.yaml handlers/bindata.go lint
|
||||
test: vendor policies.yaml api/bindata.go lint
|
||||
go test -v $(PACKAGES)
|
||||
|
||||
test-coverage: vendor policies.yaml handlers/bindata.go
|
||||
test-coverage: vendor policies.yaml api/bindata.go
|
||||
# Multiple package coverage script from https://github.com/pierrre/gotestcover
|
||||
echo 'mode: atomic' > coverage.txt && go list ./... | grep -v /vendor/ | xargs -n1 -I{} sh -c 'go test -v -covermode=atomic -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.txt' && rm coverage.tmp
|
||||
# Exclude bindata.go from coverage.
|
||||
|
@ -62,9 +62,9 @@ docker-build: main
|
|||
docker-run:
|
||||
docker run --name doorman --rm mozilla/doorman
|
||||
|
||||
api-docs: handlers/openapi.yaml
|
||||
api-docs: api/openapi.yaml
|
||||
# https://github.com/sourcey/spectacle
|
||||
spectacle --target-dir api-docs handlers/openapi.yaml
|
||||
spectacle --target-dir api-docs api/openapi.yaml
|
||||
|
||||
api-docs-publish: api-docs
|
||||
# https://github.com/tschaub/gh-pages
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
|
@ -1,4 +1,4 @@
|
|||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -1,4 +1,4 @@
|
|||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -19,6 +19,6 @@ func SetupRoutes(r *gin.Engine, d doorman.Doorman) {
|
|||
r.GET("/__lbheartbeat__", lbHeartbeatHandler)
|
||||
r.GET("/__heartbeat__", heartbeatHandler)
|
||||
r.GET("/__version__", versionHandler)
|
||||
r.GET("/__api__", YAMLAsJSONHandler("handlers/openapi.yaml"))
|
||||
r.GET("/contribute.json", YAMLAsJSONHandler("handlers/contribute.yaml"))
|
||||
r.GET("/__api__", YAMLAsJSONHandler("api/openapi.yaml"))
|
||||
r.GET("/contribute.json", YAMLAsJSONHandler("api/contribute.yaml"))
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"os"
|
|
@ -1,4 +1,4 @@
|
|||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
|
@ -1,4 +1,4 @@
|
|||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
|
@ -1,4 +1,4 @@
|
|||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
|
@ -1,5 +1,5 @@
|
|||
// Package utilities provides utility endpoints like heartbeat, OpenAPI, contribute, etc.
|
||||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
|
@ -1,4 +1,4 @@
|
|||
package handlers
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
@ -60,7 +60,7 @@ func TestVersion(t *testing.T) {
|
|||
w := performRequest(r, "GET", "/__version__", nil)
|
||||
assert.Equal(t, w.Code, http.StatusNotFound)
|
||||
|
||||
// Copy to ./handlers/
|
||||
// Copy to ./api/
|
||||
data, _ := ioutil.ReadFile("../version.json")
|
||||
ioutil.WriteFile("version.json", data, 0644)
|
||||
defer os.Remove("version.json")
|
|
@ -2,8 +2,8 @@ package config
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"strings"
|
||||
|
||||
"github.com/mozilla/doorman/doorman"
|
||||
)
|
||||
|
|
4
main.go
4
main.go
|
@ -6,9 +6,9 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/mozilla/doorman/api"
|
||||
"github.com/mozilla/doorman/config"
|
||||
"github.com/mozilla/doorman/doorman"
|
||||
"github.com/mozilla/doorman/handlers"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -40,7 +40,7 @@ func setupRouter() (*gin.Engine, error) {
|
|||
}
|
||||
|
||||
// Endpoints
|
||||
handlers.SetupRoutes(r, d)
|
||||
api.SetupRoutes(r, d)
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче