# Environment preparation
1.java 1.8, maven 3.3.3 and above, redis 2.8 and above
# Install
# Node side construction
# Download and install
- git clone https://gitee.com/fizzgate/fizz-node-extends.git to local, import into ide, such as idea:
- Modify the
application.yml
file and change the relevant configuration to the configuration of the deployment environment
# Start node
- Use IDEA to start, and the startup entry file is FizzBootstrapApplication.java
2.mvn clean package, enter the /target/fizz-gateway-community directory, and use the command to start
Linux startup: execute
chmod +x boot.sh
command to add execution permission toboot.sh
; execute./boot.sh start
command to start the service, support start/stop/restart/status commandWindows startup executes the
.\boot.cmd start
command to start the service and supports the start/stop/restart/status command.
# Management background construction
# Download and install
Download the fizz-manager-professional installation package consistent with the version of fizz-gateway-node from gitee's releases (https://gitee.com/fizzgate/fizz-gateway-node/releases)
Unzip the
fizz-manager-professional-{version}.zip
installation packageExecute the
fizz-manager-professional-{version}-mysql.sql
database script during the first installation. To upgrade from a lower version to a higher version, select and execute the corresponding upgrade script in the update directory.Modify the
application-prod.yml
file and change the relevant configuration to the configuration of the deployment environment
Modify redis configuration
Modify mysql configuration
# Start the management background
Linux startup: execute
chmod +x boot.sh
command to add execution permission toboot.sh
; execute./boot.sh start
command to start the service, support start/stop/restart/status commandWindows startup executes the
.\boot.cmd start
command to start the service and supports the start/stop/restart/status command.
# Access the management background
- After the service is started, visit http://{deployment machine IP address}:8000/#/login, and use the super administrator account
admin
passwordAa123!
to log in.
# Node side dependency description
The fizz-spring-boot-starter module is a spring boot starter, which facilitates third-party integration of the fizz gateway
fizz-commons includes common configurations, tools, etc.
fizz-core is the core of the gateway, including routing, aggregation and other logic
fizz-plugin legacy plug-in module, fizz plug-in development specifications refer to http://www.fizzgate.com/guide/plugin
# Node side project file description
com.fizzgate.plugin contains the plug-in example logPlugin
com.fizzgate.com.fizzgate.aggregate.web.flow.extension.mysql Plugin example containing aggregate nodes
# Node-side plug-in development
# Writing plug-ins
For example, if you develop a plug-in, after intercepting the request, "this is my plugin" is output to the standard error. The code is as follows:
(To facilitate demonstration, the plug-in code is placed under the fizz-plugin module. For plug-in development specifications, please refer to http://www.fizzgate.com/guide/plugin)
# Local testing
- Assume there is a back-end interface: GET http://127.0.0.1:9094/@ypath, the interface is reverse proxy by fizzgate, the corresponding front-end service is named xservice, and the front-end path is /ypath, that is, through /proxy/xservice/ypath Path access, and apply the above myPlugin to configure routing for the interface.
# Programmatic approach (for development testing only)
-Configure the test file MyApiConfig.java
- Launch the application
Start FizzBootstrapApplication.java and visit GET http://127.0.0.1:8600/proxy/xservice/ypath for testing
# Management background configuration method
- New plug-in
The plug-in name must be consistent with the id in MyPlugin.java. When multiple plug-ins are defined, the execution order of this plug-in can be preset through "Default Execution Order"
- Add new route
- Launch the application
Remove the MyApiConfig.java of the gateway, restart FizzBootstrapApplication.java, and visit GET http://127.0.0.1:8600/proxy/xservice/ypath for testing
# Aggregation node development
# Enable aggregation node
NodeFactory.registerBuilder(MysqlNode.TYPE, new MysqlNode.MysqlNodeBuilder());
###Writing aggregation files
The project contains three files:
MysqlNode.java node business logic processing
MysqlNodeConfig.java node configuration file, obtain the corresponding configuration file from the process
MysqlRPCResponse.java node final response class
Note that yes: if you need to put intermediate processing data in the context. Manual processing is required:
@Override
protected void doResponseMapping(Object responseBody) {
Map<String, Object> response = (Map<String, Object>) context.getNode(super.getName()).get("response");
synchronized (context) {
//Put body in the response in the context
response.put("body", responseBody);
}
}