# concept

The fizz plug-in can be understood as a responsive http servlet filter, which can intercept requests for processing and adjust responses.

Plugins can act on a route, i.e. all requests matching a route, or on a gateway group, i.e. a group of routes.

Plug-in development is divided into two parts: gateway and management backend. The gateway part defines the plug-in and execution logic, and the management backend defines the configuration of the plug-in.

The following takes a simple login verification as an example, that is, the client passes the login status through the request header token, and the plug-in verifies the login status to introduce the development of the plug-in.

# Gateway development

Implementing FizzPluginFilter.java defines a plug-in. In this example, the plug-in implements:

@Component(LoginValidationPlugin.ID) // Required, used to associate with the configuration of the management background, etc.
public class LoginValidationPlugin implements FizzPluginFilter {

     public static final String ID = "LoginValidationPlugin";

     @Override
     public Mono<Void> filter(ServerWebExchange exchange, Map<String, Object> config) {
         String token = exchange.getRequest().getHeaders().getFirst("token");
         if (token.equals("legal")) {
             Mono<Void> next = FizzPluginFilterChain.next(exchange); // Execute subsequent plug-ins or business logic
             return next.thenReturn(ReactorUtils.Void).flatMap(
                                                                 v -> {
                                                                     // here, do something after next
                                                                     return Mono.empty();
                                                                 }
                                                      );
         } else {
             return WebUtils.response(exchange, HttpStatus.FORBIDDEN, null, "illegal token");
         }
     }
}

# Management background configuration

# Plug-in configuration

After saving:

# Routing configuration

Edit the route to which the plugin will be applied:

After adding:

After saving, all requests matching the route will be intercepted by the plug-in.

# FizzGate integrated platform introduction

FizzGate is a microservice aggregation gateway developed based on Java. It can achieve hot service orchestration and aggregation, automatic authorization selection, online service script coding, online testing, high-performance routing, API audit management, callback management, etc., and has powerful customization The plug-in system can be expanded by itself and provides a friendly graphical configuration interface, which can quickly help enterprises manage API services, reduce middle-layer glue codes, reduce coding investment, and improve the stability and security of API services.

Official website: https://www.fizzgate.com (opens new window)

GitHub: https://github.com/fizzgate/fizz-gateway-node (opens new window)

Code cloud: https://gitee.com/fizzgate/fizz-gateway (opens new window)

Getting Started Tutorial: https://www.fizzgate.com/fizz/guide/GettingStarted/ (opens new window)

Advanced tutorial: https://www.fizzgate.com/fizz/guide/advanced/ (opens new window)


Author: lancer