Skip to content

Commit

Permalink
mw: remove Is from IsEnabledForSped
Browse files Browse the repository at this point in the history
EnabledForSpec is shorter and still means the same. This is analogous to
getters beginning with Get.
  • Loading branch information
mvdan authored and buger committed Sep 19, 2017
1 parent f15a264 commit 28757d9
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions coprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ func CoProcessInit() error {
return err
}

// IsEnabledForSpec checks if this middleware should be enabled for a given API.
func (m *CoProcessMiddleware) IsEnabledForSpec() bool {
// EnabledForSpec checks if this middleware should be enabled for a given API.
func (m *CoProcessMiddleware) EnabledForSpec() bool {
// This flag is true when Tyk has been compiled with CP support and when the configuration enables it.
enableCoProcess := config.Global.CoProcessOptions.EnableCoProcess && EnableCoProcess
// This flag indicates if the current spec specifies any CP custom middleware.
Expand Down
2 changes: 1 addition & 1 deletion coprocess_dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (m *CoProcessMiddleware) Name() string {
return "CoProcessMiddlewareDummy"
}

func (m *CoProcessMiddleware) IsEnabledForSpec() bool { return false }
func (m *CoProcessMiddleware) EnabledForSpec() bool { return false }
func (m *CoProcessMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int) {
return nil, 200
}
Expand Down
6 changes: 3 additions & 3 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type TykMiddleware interface {
Base() BaseMiddleware
Config() (interface{}, error)
ProcessRequest(w http.ResponseWriter, r *http.Request, conf interface{}) (error, int) // Handles request
IsEnabledForSpec() bool
EnabledForSpec() bool
Name() string
}

Expand Down Expand Up @@ -93,7 +93,7 @@ func createMiddleware(mw TykMiddleware) func(http.Handler) http.Handler {
}

func mwAppendEnabled(chain *[]alice.Constructor, mw TykMiddleware) {
if mw.IsEnabledForSpec() {
if mw.EnabledForSpec() {
*chain = append(*chain, createMiddleware(mw))
}
}
Expand All @@ -116,7 +116,7 @@ type BaseMiddleware struct {
func (t BaseMiddleware) Base() BaseMiddleware { return t }

func (t BaseMiddleware) Init() {}
func (t BaseMiddleware) IsEnabledForSpec() bool {
func (t BaseMiddleware) EnabledForSpec() bool {
return true
}
func (t BaseMiddleware) Config() (interface{}, error) {
Expand Down
2 changes: 1 addition & 1 deletion mw_context_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (m *MiddlewareContextVars) Name() string {
return "MiddlewareContextVars"
}

func (m *MiddlewareContextVars) IsEnabledForSpec() bool {
func (m *MiddlewareContextVars) EnabledForSpec() bool {
return m.Spec.EnableContextVars
}

Expand Down
2 changes: 1 addition & 1 deletion mw_ip_whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (i *IPWhiteListMiddleware) Name() string {
return "IPWhiteListMiddleware"
}

func (i *IPWhiteListMiddleware) IsEnabledForSpec() bool {
func (i *IPWhiteListMiddleware) EnabledForSpec() bool {
return i.Spec.EnableIpWhiteListing && len(i.Spec.AllowedIPs) > 0
}

Expand Down
2 changes: 1 addition & 1 deletion mw_method_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (t *TransformMethod) Name() string {
return "TransformMethod"
}

func (t *TransformMethod) IsEnabledForSpec() bool {
func (t *TransformMethod) EnabledForSpec() bool {
for _, version := range t.Spec.VersionData.Versions {
if len(version.ExtendedPaths.MethodTransforms) > 0 {
return true
Expand Down
2 changes: 1 addition & 1 deletion mw_modify_headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (t *TransformHeaders) Name() string {
return "TransformHeaders"
}

func (t *TransformHeaders) IsEnabledForSpec() bool {
func (t *TransformHeaders) EnabledForSpec() bool {
for _, version := range t.Spec.VersionData.Versions {
if len(version.ExtendedPaths.TransformHeader) > 0 ||
len(version.GlobalHeaders) > 0 ||
Expand Down
2 changes: 1 addition & 1 deletion mw_organisation_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (k *OrganizationMonitor) Name() string {
return "OrganizationMonitor"
}

func (k *OrganizationMonitor) IsEnabledForSpec() bool {
func (k *OrganizationMonitor) EnabledForSpec() bool {
// If false, we aren't enforcing quotas so skip this mw
// altogether
return config.Global.EnforceOrgQuotas
Expand Down
2 changes: 1 addition & 1 deletion mw_rate_limiting.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (k *RateLimitAndQuotaCheck) Name() string {
return "RateLimitAndQuotaCheck"
}

func (k *RateLimitAndQuotaCheck) IsEnabledForSpec() bool {
func (k *RateLimitAndQuotaCheck) EnabledForSpec() bool {
return !k.Spec.DisableRateLimit || !k.Spec.DisableQuota
}

Expand Down
2 changes: 1 addition & 1 deletion mw_redis_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (m *RedisCacheMiddleware) Init() {
m.sh = SuccessHandler{m.BaseMiddleware}
}

func (m *RedisCacheMiddleware) IsEnabledForSpec() bool {
func (m *RedisCacheMiddleware) EnabledForSpec() bool {
if !m.Spec.CacheOptions.EnableCache {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion mw_request_size_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (t *RequestSizeLimitMiddleware) Name() string {
return "RequestSizeLimitMiddleware"
}

func (t *RequestSizeLimitMiddleware) IsEnabledForSpec() bool {
func (t *RequestSizeLimitMiddleware) EnabledForSpec() bool {
for _, version := range t.Spec.VersionData.Versions {
if len(version.ExtendedPaths.SizeLimit) > 0 {
return true
Expand Down
2 changes: 1 addition & 1 deletion mw_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (t *TransformMiddleware) Name() string {
return "TransformMiddleware"
}

func (t *TransformMiddleware) IsEnabledForSpec() bool {
func (t *TransformMiddleware) EnabledForSpec() bool {
for _, version := range t.Spec.VersionData.Versions {
if len(version.ExtendedPaths.Transform) > 0 {
return true
Expand Down
2 changes: 1 addition & 1 deletion mw_url_rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (m *URLRewriteMiddleware) Name() string {
return "URLRewriteMiddleware"
}

func (m *URLRewriteMiddleware) IsEnabledForSpec() bool {
func (m *URLRewriteMiddleware) EnabledForSpec() bool {
for _, version := range m.Spec.VersionData.Versions {
if len(version.ExtendedPaths.URLRewrite) > 0 {
m.Spec.URLRewriteEnabled = true
Expand Down
2 changes: 1 addition & 1 deletion mw_virtual_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (d *VirtualEndpoint) Init() {
d.sh = SuccessHandler{d.BaseMiddleware}
}

func (d *VirtualEndpoint) IsEnabledForSpec() bool {
func (d *VirtualEndpoint) EnabledForSpec() bool {
if !config.Global.EnableJSVM {
return false
}
Expand Down

0 comments on commit 28757d9

Please sign in to comment.