From cde927469bc1ad59338063848d3418a841101a99 Mon Sep 17 00:00:00 2001 From: shanwb Date: Wed, 10 Jan 2024 17:02:00 +0800 Subject: [PATCH] fix mvc request method (#749) (#750) --- jcommon/docean/pom.xml | 2 +- .../src/main/java/com/xiaomi/youpin/docean/Mvc.java | 8 +++++++- jcommon/pom.xml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/jcommon/docean/pom.xml b/jcommon/docean/pom.xml index 9cb9692d4..7edcd45d1 100644 --- a/jcommon/docean/pom.xml +++ b/jcommon/docean/pom.xml @@ -10,7 +10,7 @@ 4.0.0 docean - 1.4.0 + 1.4.1-SNAPSHOT 4.1.48.Final diff --git a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java index 66dbc6346..53c4a5543 100644 --- a/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java +++ b/jcommon/docean/src/main/java/com/xiaomi/youpin/docean/Mvc.java @@ -161,8 +161,14 @@ public void callService(MvcContext context, MvcRequest request, MvcResponse resp public void callMethod(MvcContext context, MvcRequest request, MvcResponse response, MvcResult result, HttpRequestMethod method) { Safe.run(() -> { - JsonElement arguments = gson.fromJson(new String(request.getBody()), JsonElement.class); + //GET、POST + String reqMethod = request.getMethod(); String m = method.getHttpMethod(); + if (!m.equalsIgnoreCase(reqMethod)) { + throw new IllegalArgumentException(String.format("unmatched request type:%s, expect:%s", reqMethod, m.toUpperCase())); + } + + JsonElement arguments = gson.fromJson(new String(request.getBody()), JsonElement.class); MutableObject mo = getArgs(method, arguments, m); Safe.run(() -> context.setParams(arguments)); JsonElement args = mo.getObj(); diff --git a/jcommon/pom.xml b/jcommon/pom.xml index b81e73f37..a07296975 100644 --- a/jcommon/pom.xml +++ b/jcommon/pom.xml @@ -261,7 +261,7 @@ gpg - your-gpg-key +