add smart http support

This commit is contained in:
Looly
2024-12-25 14:20:24 +08:00
parent 2af90ebaa5
commit 7f12d45b4e
15 changed files with 362 additions and 219 deletions

View File

@@ -0,0 +1,27 @@
package org.dromara.hutool.http.server.engine;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.core.net.ssl.SSLContextUtil;
import org.dromara.hutool.crypto.KeyStoreUtil;
import org.dromara.hutool.http.server.ServerConfig;
import javax.net.ssl.SSLContext;
import java.security.KeyStore;
public class SmartHttpServerTest {
public static void main(final String[] args) throws Exception {
final char[] pwd = "123456".toCharArray();
final KeyStore keyStore = KeyStoreUtil.readJKSKeyStore(FileUtil.file("d:/test/keystore.jks"), pwd);
// 初始化SSLContext
final SSLContext sslContext = SSLContextUtil.createSSLContext(keyStore, pwd);
final ServerEngine engine = ServerEngineFactory.createEngine("SmartHttpServer");
engine.init(ServerConfig.of().setSslContext(sslContext));
engine.setHandler((request, response) -> {
Console.log(request.getPath());
response.write("Hutool Smart-Http response test");
});
engine.start();
}
}