Skip to content

Commit

Permalink
Middleware linted
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin committed Jul 10, 2014
1 parent 9227631 commit 185fc63
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions middleware_key_exists.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import (
"github.com/gorilla/context"
)

// KeyExists will check if the key being used to access the API is in the request data,
// and then if the key is in the storage engine
type KeyExists struct {
TykMiddleware
}

// New creates a new HttpHandler for the alice middleware package
func (k KeyExists) New() func(http.Handler) http.Handler {
aliceHandler := func(h http.Handler) http.Handler {
thisHandler := func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -29,8 +32,8 @@ func (k KeyExists) New() func(http.Handler) http.Handler {
}

// Check if API key valid
key_exists, thisSessionState := authManager.IsKeyAuthorised(authHeaderValue)
if !key_exists {
keyExists, thisSessionState := authManager.IsKeyAuthorised(authHeaderValue)
if !keyExists {
log.WithFields(logrus.Fields{
"path": r.URL.Path,
"origin": r.RemoteAddr,
Expand Down
2 changes: 2 additions & 0 deletions middleware_key_expired_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"github.com/gorilla/context"
)

// KeyExpired middleware will check if the requesting key is expired or not. It makes use of the authManager to do so.
type KeyExpired struct {
TykMiddleware
}

// New creates a new HttpHandler for the alice middleware package
func (k KeyExpired) New() func(http.Handler) http.Handler {
aliceHandler := func(h http.Handler) http.Handler {
thisHandler := func(w http.ResponseWriter, r *http.Request) {
Expand Down
3 changes: 3 additions & 0 deletions middleware_rate_limiting.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import (
"github.com/gorilla/context"
)

// RateLimitAndQuotaCheck will check the incomming request and key whether it is within it's quota and
// within it's rate limit, it makes use of the SessionLimiter object to do this
type RateLimitAndQuotaCheck struct {
TykMiddleware
}

// New creates a new HttpHandler for the alice middleware package
func (k RateLimitAndQuotaCheck) New() func(http.Handler) http.Handler {
aliceHandler := func(h http.Handler) http.Handler {
thisHandler := func(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 2 additions & 0 deletions middleware_version_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import "net/http"

import ()

// VersionCheck will check whether the version of the requested API the request is accessing has any restrictions on URL endpoints
type VersionCheck struct {
TykMiddleware
}

// New creates a new HttpHandler for the alice middleware package
func (s VersionCheck) New() func(http.Handler) http.Handler {
aliceHandler := func(h http.Handler) http.Handler {
thisHandler := func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 185fc63

Please sign in to comment.