mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-16 04:13:03 +00:00
@@ -3,9 +3,9 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>lz-cow-api</artifactId>
|
||||
<artifactId>netdisk-fast-download</artifactId>
|
||||
<groupId>cn.qaiu</groupId>
|
||||
<version>0.0.1</version>
|
||||
<version>0.1.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>1.0.8</version>
|
||||
|
||||
@@ -83,7 +83,7 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
||||
ctx.next();
|
||||
});
|
||||
// 添加跨域的方法
|
||||
router.route().handler(CorsHandler.create("*").allowCredentials(true).allowedMethods(httpMethods));
|
||||
router.route().handler(CorsHandler.create().addRelativeOrigin(".*").allowCredentials(true).allowedMethods(httpMethods));
|
||||
|
||||
// 配置文件上传路径
|
||||
router.route().handler(BodyHandler.create().setUploadsDirectory("uploads"));
|
||||
@@ -104,6 +104,7 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
||||
registerNewHandler(router, handler);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Error register {}, Error details:", handler, e.getCause());
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -181,7 +182,10 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
router.mountSubRouter(url, route);
|
||||
if (url.endsWith("*")) {
|
||||
throw new IllegalArgumentException("Don't include * when mounting a sub router");
|
||||
}
|
||||
router.route(url + "*").subRouter(route);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,8 +316,8 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
||||
}
|
||||
});
|
||||
// 解析body-json参数
|
||||
if ("application/json".equals(ctx.parsedHeaders().contentType().value()) && ctx.getBodyAsJson() != null) {
|
||||
JsonObject body = ctx.getBodyAsJson();
|
||||
if ("application/json".equals(ctx.parsedHeaders().contentType().value()) && ctx.body().asJsonObject() != null) {
|
||||
JsonObject body = ctx.body().asJsonObject();
|
||||
if (body != null) {
|
||||
methodParametersTemp.forEach((k, v) -> {
|
||||
// 只解析已配置包名前缀的实体类
|
||||
@@ -345,7 +349,7 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
||||
((Future<?>) data).onSuccess(res -> {
|
||||
if (res instanceof JsonObject) {
|
||||
fireJsonResponse(ctx, res);
|
||||
} else {
|
||||
} else if (res != null){
|
||||
fireJsonResponse(ctx, JsonResult.data(res));
|
||||
}
|
||||
}).onFailure(e -> fireJsonResponse(ctx, JsonResult.error(e.getMessage())));
|
||||
|
||||
Reference in New Issue
Block a user