mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add filter
This commit is contained in:
@@ -11,6 +11,10 @@ public class SimpleServerTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
HttpUtil.createServer(8888)
|
||||
.addFilter(((req, res, chain) -> {
|
||||
Console.log("Filter: " + req.getPath());
|
||||
chain.doFilter(req.getHttpExchange());
|
||||
}))
|
||||
// 设置默认根目录,classpath/html
|
||||
.setRoot(FileUtil.file("html"))
|
||||
// get数据测试,返回请求的PATH
|
||||
@@ -46,7 +50,10 @@ public class SimpleServerTest {
|
||||
}
|
||||
)
|
||||
// 测试输出响应内容是否能正常返回Content-Length头信息
|
||||
.addAction("test/zeroStr", (req, res)-> res.write("0"))
|
||||
.addAction("test/zeroStr", (req, res)-> {
|
||||
res.write("0");
|
||||
Console.log("Write 0 OK");
|
||||
})
|
||||
.start();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user