Closed hfguo02 closed 10 months ago
@Slf4j
@Component
public class TokenValidatorFilter implements PluginFilter {
@Override
public String name() {
return "TokenValidatorFilter";
}
@Override
public void filter(HttpRequest request, HttpResponse response, PluginFilterChain chain) {
log.info(" request info :{}", request.toString());
String path = request.getPath();
if ("mock".contains(path)) {
response.setBody("request fail!");
return;
}
chain.filter(request, response);
}
}
Confirm successful plugin startup through the following files.
2023-09-08 09:01:31,404 DEBUG epollEventLoopGroup-2-5 - [id: 0x0982b1b4] FLUSH
2023-09-08 09:01:31,404 DEBUG epollEventLoopGroup-2-5 - [id: 0x0982b1b4] READ COMPLETE
2023-09-08 09:01:31,404 DEBUG epollEventLoopGroup-2-5 - [id: 0x0982b1b4] READ: 20B
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 03 00 00 10 0c 00 00 00 00 00 06 00 04 00 00 00 |................|
|00000010| 06 00 00 00 |.... |
+--------+-------------------------------------------------+----------------+
2023-09-08 09:01:31,404 INFO epollEventLoopGroup-2-5 - request info :org.apache.apisix.plugin.runner.HttpRequest@69b6119a
2023-09-08 09:01:31,404 DEBUG epollEventLoopGroup-2-5 - [id: 0x0982b1b4] WRITE: 24B
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 02 00 00 14 0c 00 00 00 00 00 06 00 08 00 04 00 |................|
|00000010| 06 00 00 00 03 00 00 01 |........ |
+--------+-------------------------------------------------+----------------+
2023-09-08 09:01:31,404 DEBUG epollEventLoopGroup-2-5 - [id: 0x0982b1b4] FLUSH
2023-09-08 09:01:31,405 DEBUG epollEventLoopGroup-2-5 - [id: 0x0982b1b4] READ COMPLETE
Issue description
🔍After building the image and running it, the log shows that Spring Boot starts successfully. I configured the "ext-plugin-pre" in the routing, but it is not taking effect. There are no prompts or exceptions.
ℹ️Response log:172.17.0.1 - - [07/Sep/2023:10:54:27 +0000] 127.0.0.1:9080 "GET /mock HTTP/1.1" 200 7 0.055 "-" "PostmanRuntime/7.32.3" 192.168.10.78:9689 200 0.003 "http://127.0.0.1:9080"
ps:If possible, could you also tell me how to achieve plugin hot deployment using this project? Thank you.🤗
version
Dockerfile
docker image log
apisix-config
router config