mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add smart http support
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user