Ai
1 Star 0 Fork 0

Max/es4x-restful-server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 927 Bytes
一键复制 编辑 原始数据 按行查看 历史
Max 提交于 2019-09-02 13:27 +08:00 . 首次提交
/// <reference types="@vertx/core/runtime" />
// @ts-check
import {BodyHandler, Router} from "@vertx/web";
const {helloHandler, authHandler, createBook, queryBook, queryBook2, updateBook, deleteBook} = require("./router/routes");
const app = Router.router(vertx);
app.route()
.handler(BodyHandler.create())
.handler(authHandler)
.failureHandler(error => {
console.error(error.failure());
error.response().end("ERROR");
});
app.get("/hello").handler(helloHandler);
app.post("/book").handler(createBook);
app.put("/book").handler(updateBook);
app.delete("/book").handler(deleteBook);
app.post("/queryBook").handler(queryBook);
app.post("/queryBook2").handler(queryBook2);
vertx.createHttpServer()
.requestHandler(app)
.listen(8090, server => {
if (server.succeeded()) {
console.log("server start ", server.result().actualPort());
} else {
console.error(server.cause());
}
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/gnu/es4x-restful-server.git
git@gitee.com:gnu/es4x-restful-server.git
gnu
es4x-restful-server
es4x-restful-server
master

搜索帮助