Skip to content

Commit

Permalink
Rework Filter category into an enum FilterCategory
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinbunney committed Mar 9, 2022
1 parent 44da1cd commit 9191ff8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
3 changes: 2 additions & 1 deletion zuul-core/src/main/java/com/netflix/zuul/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static java.lang.annotation.RetentionPolicy.CLASS;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import com.netflix.zuul.filters.FilterCategory;
import com.netflix.zuul.filters.FilterSyncType;
import com.netflix.zuul.filters.FilterType;
import com.netflix.zuul.filters.ZuulFilter;
Expand Down Expand Up @@ -49,7 +50,7 @@
/**
* Category of the filter.
*/
String category() default "zuul";
FilterCategory category() default FilterCategory.HTTP;

/**
* Indicates if this is a synchronous filter.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2022 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.zuul.filters;

/**
* Categorization of filters.
*/
public enum FilterCategory {

ABUSE("abuse", "Abuse detection and protection filters, such as rate-limiting, malicious request detection, geo-blocking"),
ACCESS("access", "Authentication and authorization filters"),
ADMIN("admin", "Admin only filters providing operational support"),
CHAOS("chaos", "Failure injection testing and resilience support"),
CONTEXT_DECORATOR("context-decorator", "Decorate context based on request and detected client"),
HEALTHCHECK("healthcheck", "Support for healthcheck endpoints"),
HTTP("http", "Filter operating on HTTP request/response protocol features"),
ORIGIN("origin", "Origin connectivity filters"),
OBSERVABILITY("observability", "Filters providing observability features"),
OVERLOAD("overload", "Filters to respond on the server being in an overloaded state such as brownout"),
ROUTING("routing", "Filters which make routing decisions"),
;

private final String code;
private final String description;

FilterCategory(String code, String description) {
this.code = code;
this.description = description;
}

public String getCode() {
return code;
}

public String getDescription() {
return description;
}

@Override
public String toString() {
return code;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ default FilterType filterType() {
/**
* Classify a filter by category.
*
* @return String the classification of this filter
* @return FilterCategory the classification of this filter
*/
default String category() {
default FilterCategory category() {
Filter f = getClass().getAnnotation(Filter.class);
if (f != null) {
return f.category();
Expand Down

0 comments on commit 9191ff8

Please sign in to comment.