Skip to content

Commit

Permalink
Lowercase most of the non-var style variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdan authored and lonelycode committed Mar 2, 2017
1 parent 213f046 commit efc66e2
Show file tree
Hide file tree
Showing 23 changed files with 243 additions and 243 deletions.
174 changes: 87 additions & 87 deletions api.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions api_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,8 @@ func (a *APISpec) GetVersionData(r *http.Request) (*apidef.VersionInfo, []URLSpe
}

// Load path data and whitelist data for version
RxPaths, rxOk := a.RxPaths[versionKey]
WhiteListStatus, wlOk := a.WhiteListEnabled[versionKey]
rxPaths, rxOk := a.RxPaths[versionKey]
whiteListStatus, wlOk := a.WhiteListEnabled[versionKey]

if !rxOk {
log.Error("no RX Paths found for version")
Expand All @@ -1139,8 +1139,8 @@ func (a *APISpec) GetVersionData(r *http.Request) (*apidef.VersionInfo, []URLSpe
return &version, versionRxPaths, versionWLStatus, VersionWhiteListStatusNotFound
}

versionRxPaths = RxPaths
versionWLStatus = WhiteListStatus
versionRxPaths = rxPaths
versionWLStatus = whiteListStatus

return &version, versionRxPaths, versionWLStatus, StatusOk

Expand Down
8 changes: 4 additions & 4 deletions api_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ func processSpec(referenceSpec *APISpec,
CheckETEnabled(tykMiddleware)

keyPrefix := "cache-" + referenceSpec.APIDefinition.APIID
CacheStore := &RedisClusterStorageManager{KeyPrefix: keyPrefix, IsCache: true}
CacheStore.Connect()
cacheStore := &RedisClusterStorageManager{KeyPrefix: keyPrefix, IsCache: true}
cacheStore.Connect()

var chain http.Handler

Expand All @@ -289,7 +289,7 @@ func processSpec(referenceSpec *APISpec,
AppendMiddleware(&baseChainArray, &TrackEndpointMiddleware{tykMiddleware}, tykMiddleware)
AppendMiddleware(&baseChainArray, &TransformMiddleware{tykMiddleware}, tykMiddleware)
AppendMiddleware(&baseChainArray, &TransformHeaders{TykMiddleware: tykMiddleware}, tykMiddleware)
AppendMiddleware(&baseChainArray, &RedisCacheMiddleware{TykMiddleware: tykMiddleware, CacheStore: CacheStore}, tykMiddleware)
AppendMiddleware(&baseChainArray, &RedisCacheMiddleware{TykMiddleware: tykMiddleware, CacheStore: cacheStore}, tykMiddleware)
AppendMiddleware(&baseChainArray, &VirtualEndpoint{TykMiddleware: tykMiddleware}, tykMiddleware)
AppendMiddleware(&baseChainArray, &URLRewriteMiddleware{TykMiddleware: tykMiddleware}, tykMiddleware)
AppendMiddleware(&baseChainArray, &TransformMethod{TykMiddleware: tykMiddleware}, tykMiddleware)
Expand Down Expand Up @@ -465,7 +465,7 @@ func processSpec(referenceSpec *APISpec,
AppendMiddleware(&baseChainArray_PostAuth, &TransformMiddleware{tykMiddleware}, tykMiddleware)
AppendMiddleware(&baseChainArray_PostAuth, &TransformHeaders{TykMiddleware: tykMiddleware}, tykMiddleware)
AppendMiddleware(&baseChainArray_PostAuth, &URLRewriteMiddleware{TykMiddleware: tykMiddleware}, tykMiddleware)
AppendMiddleware(&baseChainArray_PostAuth, &RedisCacheMiddleware{TykMiddleware: tykMiddleware, CacheStore: CacheStore}, tykMiddleware)
AppendMiddleware(&baseChainArray_PostAuth, &RedisCacheMiddleware{TykMiddleware: tykMiddleware, CacheStore: cacheStore}, tykMiddleware)
AppendMiddleware(&baseChainArray_PostAuth, &TransformMethod{TykMiddleware: tykMiddleware}, tykMiddleware)
AppendMiddleware(&baseChainArray_PostAuth, &VirtualEndpoint{TykMiddleware: tykMiddleware}, tykMiddleware)

Expand Down
16 changes: 8 additions & 8 deletions batch_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (b *BatchRequestHandler) ConstructRequests(batchRequest BatchRequestStructu
}

func (b *BatchRequestHandler) MakeRequests(batchRequest BatchRequestStructure, requestSet []*http.Request) []BatchReplyUnit {
ReplySet := []BatchReplyUnit{}
replySet := []BatchReplyUnit{}

if len(batchRequest.Requests) != len(requestSet) {
log.Error("Something went wrong creating requests, they are of mismatched lengths!", len(batchRequest.Requests), len(requestSet))
Expand All @@ -135,16 +135,16 @@ func (b *BatchRequestHandler) MakeRequests(batchRequest BatchRequestStructure, r
}

for range batchRequest.Requests {
ReplySet = append(ReplySet, <-replies)
replySet = append(replySet, <-replies)
}
} else {
for index, req := range requestSet {
reply := b.doSyncRequest(req, batchRequest.Requests[index].RelativeURL)
ReplySet = append(ReplySet, reply)
replySet = append(replySet, reply)
}
}

return ReplySet
return replySet
}

// HandleBatchRequest is the actual http handler for a batch request on an API definition
Expand All @@ -169,10 +169,10 @@ func (b *BatchRequestHandler) HandleBatchRequest(w http.ResponseWriter, r *http.
}

// Run requests and collate responses
ReplySet := b.MakeRequests(batchRequest, requestSet)
replySet := b.MakeRequests(batchRequest, requestSet)

// Encode responses
replyMessage, err := json.Marshal(&ReplySet)
replyMessage, err := json.Marshal(&replySet)
if err != nil {
log.Error("Couldn't encode response to string! ", err)
return
Expand Down Expand Up @@ -200,10 +200,10 @@ func (b *BatchRequestHandler) ManualBatchRequest(RequestObject []byte) []byte {
}

// Run requests and collate responses
ReplySet := b.MakeRequests(batchRequest, requestSet)
replySet := b.MakeRequests(batchRequest, requestSet)

// Encode responses
replyMessage, err := json.Marshal(&ReplySet)
replyMessage, err := json.Marshal(&replySet)
if err != nil {
log.Error("Couldn't encode response to string! ", err)
return nil
Expand Down
12 changes: 6 additions & 6 deletions coprocess_id_extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func TestValueExtractorHeaderSource(t *testing.T) {
chain := getBasicAuthChain(spec)
chain.ServeHTTP(recorder, req)

SessionID, returnOverrides := extractor.ExtractAndCheck(req)
_, _ = SessionID, returnOverrides
sessionID, returnOverrides := extractor.ExtractAndCheck(req)
_, _ = sessionID, returnOverrides
}

/* Value Extractor tests, using "form" source */
Expand Down Expand Up @@ -96,10 +96,10 @@ func TestValueExtractorFormSource(t *testing.T) {
chain := getBasicAuthChain(spec)
chain.ServeHTTP(recorder, req)

SessionID, _ := extractor.ExtractAndCheck(req)
sessionID, _ := extractor.ExtractAndCheck(req)
expectedSessionID := computeSessionID([]byte(authValue), tykMiddleware)

if SessionID != expectedSessionID {
if sessionID != expectedSessionID {
t.Fatal("Value Extractor output (using form source) doesn't match the computed session ID.")
}
}
Expand Down Expand Up @@ -175,10 +175,10 @@ func TestRegexExtractorHeaderSource(t *testing.T) {
chain := getBasicAuthChain(spec)
chain.ServeHTTP(recorder, req)

SessionID, _ := extractor.ExtractAndCheck(req)
sessionID, _ := extractor.ExtractAndCheck(req)
expectedSessionID := computeSessionID(matchedHeaderValue, tykMiddleware)

if SessionID != expectedSessionID {
if sessionID != expectedSessionID {
t.Fatal("Regex Extractor output doesn't match the computed session ID.")
}

Expand Down
6 changes: 3 additions & 3 deletions handler_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ func (e *ErrorHandler) HandleError(w http.ResponseWriter, r *http.Request, errMs
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/")
}

OauthClientID := ""
oauthClientID := ""
tags := make([]string, 0)
sessionState := context.Get(r, SessionData)

if sessionState != nil {
OauthClientID = sessionState.(SessionState).OauthClientID
oauthClientID = sessionState.(SessionState).OauthClientID
alias = sessionState.(SessionState).Alias
tags = sessionState.(SessionState).Tags
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func (e *ErrorHandler) HandleError(w http.ResponseWriter, r *http.Request, errMs
e.Spec.APIDefinition.Name,
e.Spec.APIDefinition.APIID,
e.Spec.APIDefinition.OrgID,
OauthClientID,
oauthClientID,
0,
rawRequest,
rawResponse,
Expand Down
6 changes: 3 additions & 3 deletions handler_success.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ func (s *SuccessHandler) RecordHit(w http.ResponseWriter, r *http.Request, timin
}

// If OAuth, we need to grab it from the session, which may or may not exist
OauthClientID := ""
oauthClientID := ""
tags := make([]string, 0)
var alias string
sessionState := context.Get(r, SessionData)

if sessionState != nil {
OauthClientID = sessionState.(SessionState).OauthClientID
oauthClientID = sessionState.(SessionState).OauthClientID
tags = sessionState.(SessionState).Tags
alias = sessionState.(SessionState).Alias
}
Expand Down Expand Up @@ -301,7 +301,7 @@ func (s *SuccessHandler) RecordHit(w http.ResponseWriter, r *http.Request, timin
s.Spec.APIDefinition.Name,
s.Spec.APIDefinition.APIID,
s.Spec.APIDefinition.OrgID,
OauthClientID,
oauthClientID,
timing,
rawRequest,
rawResponse,
Expand Down
6 changes: 3 additions & 3 deletions host_checker_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (hc *HostCheckerManager) AmIPolling() bool {
}).Error("No storage instance set for uptime tests! Disabling poller...")
return false
}
ActiveInstance, err := hc.store.GetKey(PollerCacheKey)
activeInstance, err := hc.store.GetKey(PollerCacheKey)
if err != nil {
log.WithFields(logrus.Fields{
"prefix": "host-check-mgr",
Expand All @@ -139,7 +139,7 @@ func (hc *HostCheckerManager) AmIPolling() bool {
return true
}

if ActiveInstance == hc.Id {
if activeInstance == hc.Id {
log.WithFields(logrus.Fields{
"prefix": "host-check-mgr",
}).Debug("Primary instance set, I am master")
Expand All @@ -149,7 +149,7 @@ func (hc *HostCheckerManager) AmIPolling() bool {

log.WithFields(logrus.Fields{
"prefix": "host-check-mgr",
}).Debug("Active Instance is: ", ActiveInstance)
}).Debug("Active Instance is: ", activeInstance)
log.WithFields(logrus.Fields{
"prefix": "host-check-mgr",
}).Debug("--- I am: ", hc.Id)
Expand Down
32 changes: 16 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,26 @@ func setupGlobals() {
}

// Initialise our Host Checker
HealthCheckStore := &RedisClusterStorageManager{KeyPrefix: "host-checker:"}
InitHostCheckManager(HealthCheckStore)
healthCheckStore := &RedisClusterStorageManager{KeyPrefix: "host-checker:"}
InitHostCheckManager(healthCheckStore)

if config.EnableAnalytics {
config.loadIgnoredIPs()
AnalyticsStore := RedisClusterStorageManager{KeyPrefix: "analytics-"}
analyticsStore := RedisClusterStorageManager{KeyPrefix: "analytics-"}
log.WithFields(logrus.Fields{
"prefix": "main",
}).Debug("Setting up analytics DB connection")

analytics = RedisAnalyticsHandler{
Store: &AnalyticsStore,
Store: &analyticsStore,
}

analytics.Init()

if config.AnalyticsConfig.Type == "rpc" {
log.Debug("Using RPC cache purge")

purger := RPCPurger{Store: &AnalyticsStore}
purger := RPCPurger{Store: &analyticsStore}
purger.Connect()
analytics.Clean = &purger
go analytics.Clean.PurgeLoop(10 * time.Second)
Expand All @@ -174,9 +174,9 @@ func setupGlobals() {
log.WithFields(logrus.Fields{
"prefix": "main",
}).Debug("Notifier will not work in hybrid mode")
MainNotifierStore := RedisClusterStorageManager{}
MainNotifierStore.Connect()
MainNotifier = RedisNotifier{&MainNotifierStore, RedisPubSubChannel}
mainNotifierStore := RedisClusterStorageManager{}
mainNotifierStore.Connect()
MainNotifier = RedisNotifier{&mainNotifierStore, RedisPubSubChannel}

if config.Monitor.EnableTriggerMonitors {
var err error
Expand Down Expand Up @@ -1260,15 +1260,15 @@ func startDRL() {
}

func listen(l net.Listener, controlListener net.Listener, err error) {
ReadTimeout := 120
WriteTimeout := 120
readtimeout := 120
writeTimeout := 120
targetPort := fmt.Sprintf("%s:%d", config.ListenAddress, config.ListenPort)
if config.HttpServerOptions.ReadTimeout > 0 {
ReadTimeout = config.HttpServerOptions.ReadTimeout
readtimeout = config.HttpServerOptions.ReadTimeout
}

if config.HttpServerOptions.WriteTimeout > 0 {
WriteTimeout = config.HttpServerOptions.WriteTimeout
writeTimeout = config.HttpServerOptions.WriteTimeout
}

// Handle reload when SIGUSR2 is received
Expand Down Expand Up @@ -1307,8 +1307,8 @@ func listen(l net.Listener, controlListener net.Listener, err error) {
}).Warning("HTTP Server Overrides detected, this could destabilise long-running http-requests")
s := &http.Server{
Addr: ":" + targetPort,
ReadTimeout: time.Duration(ReadTimeout) * time.Second,
WriteTimeout: time.Duration(WriteTimeout) * time.Second,
ReadTimeout: time.Duration(readtimeout) * time.Second,
WriteTimeout: time.Duration(writeTimeout) * time.Second,
Handler: defaultRouter,
}

Expand Down Expand Up @@ -1370,8 +1370,8 @@ func listen(l net.Listener, controlListener net.Listener, err error) {
}).Warning("HTTP Server Overrides detected, this could destabilise long-running http-requests")
s := &http.Server{
Addr: ":" + targetPort,
ReadTimeout: time.Duration(ReadTimeout) * time.Second,
WriteTimeout: time.Duration(WriteTimeout) * time.Second,
ReadTimeout: time.Duration(readtimeout) * time.Second,
WriteTimeout: time.Duration(writeTimeout) * time.Second,
Handler: defaultRouter,
}

Expand Down
14 changes: 7 additions & 7 deletions middleware_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ func (k *JWTMiddleware) processCentralisedJWT(w http.ResponseWriter, r *http.Req
log.Debug("Base Field ID set to: ", baseFieldData)
data := []byte(baseFieldData)
tokenID = fmt.Sprintf("%x", md5.Sum(data))
SessionID := k.TykMiddleware.Spec.OrgID + tokenID
sessionID := k.TykMiddleware.Spec.OrgID + tokenID

log.Debug("JWT Temporary session ID is: ", SessionID)
log.Debug("JWT Temporary session ID is: ", sessionID)

sessionState, exists := k.TykMiddleware.CheckSessionAndIdentityForValidKey(SessionID)
sessionState, exists := k.TykMiddleware.CheckSessionAndIdentityForValidKey(sessionID)
if !exists {
// Create it
log.Debug("Key does not exist, creating")
Expand All @@ -250,17 +250,17 @@ func (k *JWTMiddleware) processCentralisedJWT(w http.ResponseWriter, r *http.Req

if err == nil {
sessionState = newSessionState
sessionState.MetaData = map[string]interface{}{"TykJWTSessionID": SessionID}
sessionState.MetaData = map[string]interface{}{"TykJWTSessionID": sessionID}
sessionState.Alias = baseFieldData

// Update the session in the session manager in case it gets called again
k.Spec.SessionManager.UpdateSession(SessionID, sessionState, GetLifetime(k.Spec, &sessionState))
k.Spec.SessionManager.UpdateSession(sessionID, sessionState, GetLifetime(k.Spec, &sessionState))
log.Debug("Policy applied to key")

switch k.TykMiddleware.Spec.BaseIdentityProvidedBy {
case apidef.JWTClaim, apidef.UnsetAuth:
context.Set(r, SessionData, sessionState)
context.Set(r, AuthHeaderValue, SessionID)
context.Set(r, AuthHeaderValue, sessionID)
}
k.setContextVars(r, token)
return nil, 200
Expand All @@ -275,7 +275,7 @@ func (k *JWTMiddleware) processCentralisedJWT(w http.ResponseWriter, r *http.Req
switch k.TykMiddleware.Spec.BaseIdentityProvidedBy {
case apidef.JWTClaim, apidef.UnsetAuth:
context.Set(r, SessionData, sessionState)
context.Set(r, AuthHeaderValue, SessionID)
context.Set(r, AuthHeaderValue, sessionID)
}
k.setContextVars(r, token)
return nil, 200
Expand Down
Loading

0 comments on commit efc66e2

Please sign in to comment.