diff --git a/README.md b/README.md index 44cf03758..f47a90058 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This is a lightweight, API Gateway and Management Platform enables you to control who accesses your API, when they access it and how they access it. API Gateway will also record detailed analytics on how your -users are interacting with your API and when things go wrong. +users are interacting with your API and when things go wrong. ## What is an API Gateway? @@ -18,7 +18,7 @@ services instead of implementing management infrastructure. For example if you h web service that provides geolocation data for all the cats in NYC, and you want to make it public, integrating an API gateway is a faster, more secure route that writing your own authorisation middleware. -## Key Features +## Key Features This API Gateway offers powerful, yet lightweight features that allow fine gained control over your API ecosystem. diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 4b4babdf4..500357793 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -174,12 +174,6 @@ jobs: context: unit-tests status: pending - - put: prequest - params: - path: prequest - context: api-tests - status: pending - - aggregate: - task: pullrequest unit test config: @@ -191,7 +185,7 @@ jobs: username: {{quay_username}} password: {{quay_password}} run: - path: ci/tasks/unit-tests.sh + path: ./ci/tasks/unit-tests.sh dir: prequest inputs: - name: prequest @@ -209,3 +203,4 @@ jobs: status: success params: PROJECT_SRC: {{project_src}} + diff --git a/ci/tasks/unit-tests-pr.yml b/ci/tasks/unit-tests-pr.yml deleted file mode 100644 index 275423c1a..000000000 --- a/ci/tasks/unit-tests-pr.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -platform: linux - -image_resource: - type: docker-image - source: - repository: quay.io/hellofresh/api-gateway - username: {{quay_username}} - password: {{quay_password}} - -run: - path: api-gateway/ci/tasks/unit-tests.sh - -inputs: -- name: prequest \ No newline at end of file diff --git a/ci/tasks/unit-tests.sh b/ci/tasks/unit-tests.sh index 4e0abf655..b5fee78af 100755 --- a/ci/tasks/unit-tests.sh +++ b/ci/tasks/unit-tests.sh @@ -1,4 +1,5 @@ #!/bin/sh cd ${PROJECT_SRC} +pwd make test \ No newline at end of file diff --git a/main.go b/main.go index e26cabcff..93c26f99a 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,6 @@ var config Specification //loadConfigEnv loads environment variables func loadConfigEnv() Specification { err := envconfig.Process("", &config) - log.Info(config) if err != nil { log.Fatal(err.Error()) } @@ -72,6 +71,7 @@ func main() { accessor := initializeDatabase() defer accessor.Close() + database := Database{accessor} router.Use(database.Middleware()) diff --git a/middleware_rate_limit.go b/middleware_rate_limit.go index f62c0ab29..98940f87e 100644 --- a/middleware_rate_limit.go +++ b/middleware_rate_limit.go @@ -6,9 +6,10 @@ import ( "strconv" "time" + "net/http" + "github.com/etcinit/speedbump" "github.com/gin-gonic/gin" - "net/http" ) type RateLimitMiddleware struct { @@ -46,7 +47,7 @@ func (m RateLimitMiddleware) ProcessRequest(req *http.Request, c *gin.Context) ( if !ok { m.Logger.Debug("Rate limit exceeded.") return errors.New("Rate limit exceeded. Try again in " + nextTime.String()), http.StatusTooManyRequests - } else { - return nil, http.StatusOK } + + return nil, http.StatusOK }