<mark>此插件，由社区成员（阿楠同学）协助贡献</mark>

```xml
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>solon-server-vertx</artifactId>
</dependency>
```

#### 1、描述

通讯扩展插件，基于 vertx-core（[代码仓库](https://github.com/eclipse-vertx/vert.x)）的http信号服务适配。可用于 Api 开发、Rpc 开发、Mvc web 开发、分布式网关开发。v2.9.1 后支持



**支持信号：**

| 信号 | 说明 | 
| -------- | -------- | 
| http     | 默认端口 8080，可由 `server.port` 或 `server.http.port` 配置     | 




#### 2、应用示例

```java
public class DemoApp {
    public static void main(String[] args) {
        Solon.start(DemoApp.class, args);
    }
}

@Controller
public class DemoController{
    @Mapping("/hello")
    public String hello(){
        return "Hello world!";
    }
}
```

#### 3、添加 ssl 证书配置，启用 https 支持（极少有需求会用到）

```yml
server.ssl.keyStore: "/data/_ca/demo.jks" #或 "demo.pfx"
server.ssl.keyPassword: "demo"
```

更多配置，可参考：[《应用常用配置说明》](/article/174)


#### 4、添加 http 端口（极少有需求会用到）

一般是在启用 https 之后，仍想要有一个 http 端口时，才会使用。 v2.2.18 后支持

```java
@SolonMain
public class SeverDemo {
    public static void main(String[] args) {
        Solon.start(SeverDemo.class, args, app -> {
            app.onEvent(HttpServerConfigure.class, e -> {
                e.addHttpPort(8082);
            });
        });
    }
}
```



#### 5、控制 http 端口启停（极少有需求会用到）

关掉 http 启用（就是关掉，自动启动）

```java
@SolonMain
public class SeverDemo {
    public static void main(String[] args) {
        Solon.start(SeverDemo.class, args, app -> {
            app.enableHttp(false);
        });
    }
}
```

使用 VxHttpServer 类（细节看类里的接口）


```java
VxHttpServer server = new VxHttpServer();

//启动
server.start(null, 8080);

//停止
server.stop();
```

